[edk2-devel] [PATCH 1/1] SecurityPkg/AuthVariableLib: Check SHA-256 OID with ContentInfo present

2022-12-02 Thread Jan Bobek via groups.io
Based on whether the DER-encoded ContentInfo structure is present in
authenticated SetVariable payload or not, the SHA-256 OID can be
located at different places.

UEFI specification explicitly states the driver shall support both
cases, but the old code assumed ContentInfo was not present and
incorrectly rejected authenticated variable updates when it were
present.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Min Xu 
Signed-off-by: Jan Bobek 
---
 .../Library/AuthVariableLib/AuthService.c  | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c 
b/SecurityPkg/Library/AuthVariableLib/AuthService.c
index 054ee4d1d988..de8baccab410 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
@@ -1933,15 +1933,19 @@ VerifyTimeBasedPayload (
   // }
   //The DigestAlgorithmIdentifiers can be used to determine the hash 
algorithm
   //in VARIABLE_AUTHENTICATION_2 descriptor.
-  //This field has the fixed offset (+13) and be calculated based on two 
bytes of length encoding.
+  //This field has the fixed offset (+13) or (+32) based on whether the 
DER-encoded
+  //ContentInfo structure is present or not, and can be calculated based 
on two
+  //bytes of length encoding.
   //
   if ((Attributes & EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS) != 0) {
-if (SigDataSize >= (13 + sizeof (mSha256OidValue))) {
-  if (((*(SigData + 1) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE) ||
-  (CompareMem (SigData + 13, &mSha256OidValue, sizeof 
(mSha256OidValue)) != 0))
-  {
-return EFI_SECURITY_VIOLATION;
-  }
+if (  (  (SigDataSize >= (13 + sizeof (mSha256OidValue)))
+  && (  ((*(SigData + 1) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE)
+ || (CompareMem (SigData + 13, &mSha256OidValue, sizeof 
(mSha256OidValue)) != 0)))
+   && (  (SigDataSize >= (32 + sizeof (mSha256OidValue)))
+  && (  ((*(SigData + 20) & TWO_BYTE_ENCODE) != TWO_BYTE_ENCODE)
+ || (CompareMem (SigData + 32, &mSha256OidValue, sizeof 
(mSha256OidValue)) != 0
+{
+  return EFI_SECURITY_VIOLATION;
 }
   }
 
-- 
2.30.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96926): https://edk2.groups.io/g/devel/message/96926
Mute This Topic: https://groups.io/mt/95419835/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/3] UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support

2022-12-02 Thread Rebecca Cran
The SendRndisSetMsg function never appears to be called: never directly, 
or as a callback.


I noticed this because qemu's rndis receive function always fails 
because the media status is 'uninitialized': it uses the RNDIS SET MSG 
to change the status to initialized.


--
Rebecca Cran

On 10/3/22 03:26, RichardHo [何明忠] via groups.io wrote:

This driver provides UEFI driver for USB RNDIS device

Signed-off-by: Richard Ho 
Cc: Andrew Fish 
Cc: Leif Lindholm 
Cc: Michael D Kinney 
Cc: Michael Kubacki 
Cc: Zhiguang Liu 
Cc: Liming Gao 
Reviewed-by: Tony Lo 
---
  UsbNetworkPkg/Config/UsbNetworkPkg.inc.dsc|9 +
  .../Config/UsbNetworkPkgComponentsDxe.inc.dsc |   20 +
  .../Config/UsbNetworkPkgComponentsDxe.inc.fdf |   20 +
  .../Config/UsbNetworkPkgDefines.inc.dsc   |   23 +
  .../Protocol/EdkIIUsbEthernetProtocol.h   |  874 +
  UsbNetworkPkg/NetworkCommon/ComponentName.c   |  263 +++
  UsbNetworkPkg/NetworkCommon/DriverBinding.c   |  581 ++
  UsbNetworkPkg/NetworkCommon/DriverBinding.h   |  263 +++
  UsbNetworkPkg/NetworkCommon/NetworkCommon.inf |   44 +
  UsbNetworkPkg/NetworkCommon/PxeFunction.c | 1734 +
  UsbNetworkPkg/ReadMe.md   |   65 +
  UsbNetworkPkg/ReleaseNotes.md |   11 +
  UsbNetworkPkg/UsbNetworkPkg.dec   |   36 +
  UsbNetworkPkg/UsbRndis/ComponentName.c|  172 ++
  UsbNetworkPkg/UsbRndis/UsbRndis.c |  845 
  UsbNetworkPkg/UsbRndis/UsbRndis.h |  571 ++
  UsbNetworkPkg/UsbRndis/UsbRndis.inf   |   42 +
  UsbNetworkPkg/UsbRndis/UsbRndisFunction.c | 1591 +++
  18 files changed, 7164 insertions(+)
  create mode 100644 UsbNetworkPkg/Config/UsbNetworkPkg.inc.dsc
  create mode 100644 UsbNetworkPkg/Config/UsbNetworkPkgComponentsDxe.inc.dsc
  create mode 100644 UsbNetworkPkg/Config/UsbNetworkPkgComponentsDxe.inc.fdf
  create mode 100644 UsbNetworkPkg/Config/UsbNetworkPkgDefines.inc.dsc
  create mode 100644 UsbNetworkPkg/Include/Protocol/EdkIIUsbEthernetProtocol.h
  create mode 100644 UsbNetworkPkg/NetworkCommon/ComponentName.c
  create mode 100644 UsbNetworkPkg/NetworkCommon/DriverBinding.c
  create mode 100644 UsbNetworkPkg/NetworkCommon/DriverBinding.h
  create mode 100644 UsbNetworkPkg/NetworkCommon/NetworkCommon.inf
  create mode 100644 UsbNetworkPkg/NetworkCommon/PxeFunction.c
  create mode 100644 UsbNetworkPkg/ReadMe.md
  create mode 100644 UsbNetworkPkg/ReleaseNotes.md
  create mode 100644 UsbNetworkPkg/UsbNetworkPkg.dec
  create mode 100644 UsbNetworkPkg/UsbRndis/ComponentName.c
  create mode 100644 UsbNetworkPkg/UsbRndis/UsbRndis.c
  create mode 100644 UsbNetworkPkg/UsbRndis/UsbRndis.h
  create mode 100644 UsbNetworkPkg/UsbRndis/UsbRndis.inf
  create mode 100644 UsbNetworkPkg/UsbRndis/UsbRndisFunction.c



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




Re: [edk2-devel] [PATCH v10 07/17] CI: Use Fedora 35 container (Linux only)

2022-12-02 Thread Michael Kubacki

Reviewed-by: Michael Kubacki 

On 12/1/2022 3:28 PM, Oliver Steffen wrote:

Run all Linux based jobs in a container, using a custom Fedora 35 image
(gcc 11). The image is hosted on ghcr.io and the Dockerfiles are
here: https://github.com/tianocore/containers
The version numbers of gcc, iasl, and nasm are pinned to avoid
unintended upgrades during image rebuild.

Do not run apt-get in CI jobs to install qemu and gcc dependencies.
Assume the container image provides these.

Use Python from the container image, do not download at runtime.

Signed-off-by: Oliver Steffen 
---
  .azurepipelines/Ubuntu-GCC5.yml | 6 ++
  .azurepipelines/templates/basetools-build-steps.yml | 9 -
  2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/.azurepipelines/Ubuntu-GCC5.yml b/.azurepipelines/Ubuntu-GCC5.yml
index 4ed6cb601b8e..ca23b684e222 100644
--- a/.azurepipelines/Ubuntu-GCC5.yml
+++ b/.azurepipelines/Ubuntu-GCC5.yml
@@ -13,14 +13,12 @@ pr:
  - master
  - stable/*

-variables:
-  - template: templates/defaults.yml
-
  jobs:
  - template: templates/pr-gate-build-job.yml
parameters:
  tool_chain_tag: 'GCC5'
  vm_image: 'ubuntu-latest'
+container: 'ghcr.io/tianocore/containers/fedora-35-build:2113a0e'
  arch_list: "IA32,X64,ARM,AARCH64,RISCV64,LOONGARCH64"
-usePythonVersion: ${{ variables.default_python_version }}
+usePythonVersion: ''  # use Python from the container image

diff --git a/.azurepipelines/templates/basetools-build-steps.yml
b/.azurepipelines/templates/basetools-build-steps.yml
index d8c108c6e212..a72758bc3395 100644
--- a/.azurepipelines/templates/basetools-build-steps.yml
+++ b/.azurepipelines/templates/basetools-build-steps.yml
@@ -10,15 +10,6 @@ parameters:
tool_chain_tag: ''

  steps:
-- ${{ if contains(parameters.tool_chain_tag, 'GCC') }}:
-  - bash: sudo apt-get update
-displayName: Update apt
-condition: and(gt(variables.pkg_count, 0), succeeded())
-
-  - bash: sudo apt-get install gcc g++ make uuid-dev
-displayName: Install required tools
-condition: and(gt(variables.pkg_count, 0), succeeded())
-
  - task: CmdLine@1
displayName: Build Base Tools from source
inputs:



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




[edk2-devel] [edk2-staging/HttpProxy PATCH v3 7/7] NetworkPkg/HttpBootDxe: Add Proxy URI input in setup menu

2022-12-02 Thread Saloni Kasbekar
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3951

Allows users to input the Proxy Server URI in the
HTTP setup menu

Cc: Maciej Rabeda 
Cc: Wu Jiaxin 
Cc: Siyuan Fu 
Signed-off-by: Saloni Kasbekar 
---
 NetworkPkg/HttpBootDxe/HttpBootConfig.c   | 99 ++-
 .../HttpBootDxe/HttpBootConfigNVDataStruc.h   |  4 +-
 .../HttpBootDxe/HttpBootConfigStrings.uni |  2 +
 NetworkPkg/HttpBootDxe/HttpBootConfigVfr.vfr  |  9 ++
 4 files changed, 88 insertions(+), 26 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootConfig.c 
b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
index 42d3fdc1fb..2cdd5043fe 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootConfig.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootConfig.c
@@ -18,6 +18,7 @@ CHAR16  mHttpBootConfigStorageName[] = 
L"HTTP_BOOT_CONFIG_IFR_NVDATA";
   @param[in]  UsingIpv6   Set to TRUE if creating boot option for IPv6.
   @param[in]  Description The description text of the boot option.
   @param[in]  Uri The URI string of the boot file.
+  @param[in]  ProxyUriThe Proxy URI string for the boot path.
 
   @retval EFI_SUCCESS The boot option is created successfully.
   @retval Others  Failed to create new boot option.
@@ -28,48 +29,59 @@ HttpBootAddBootOption (
   IN   HTTP_BOOT_PRIVATE_DATA  *Private,
   IN   BOOLEAN UsingIpv6,
   IN   CHAR16  *Description,
-  IN   CHAR16  *Uri
+  IN   CHAR16  *Uri,
+  IN   CHAR16  *ProxyUri
   )
 {
   EFI_DEV_PATH  *Node;
   EFI_DEVICE_PATH_PROTOCOL  *TmpDevicePath;
   EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;
+  EFI_DEVICE_PATH_PROTOCOL  *FinalDevicePath;
   UINTN Length;
   CHAR8 AsciiUri[URI_STR_MAX_SIZE];
+  CHAR8 AsciiProxyUri[URI_STR_MAX_SIZE];
+  UINTN AsciiProxyUriSize;
   EFI_STATUSStatus;
-  UINTN Index;
   EFI_BOOT_MANAGER_LOAD_OPTION  NewOption;
 
-  NewDevicePath = NULL;
-  Node  = NULL;
-  TmpDevicePath = NULL;
+  NewDevicePath   = NULL;
+  Node= NULL;
+  TmpDevicePath   = NULL;
+  FinalDevicePath = NULL;
 
   if (StrLen (Description) == 0) {
 return EFI_INVALID_PARAMETER;
   }
 
   //
-  // Convert the scheme to all lower case.
+  // Check the URI Scheme
   //
-  for (Index = 0; Index < StrLen (Uri); Index++) {
-if (Uri[Index] == L':') {
-  break;
+  UnicodeStrToAsciiStrS (Uri, AsciiUri, sizeof (AsciiUri));
+  UnicodeStrToAsciiStrS (ProxyUri, AsciiProxyUri, sizeof (AsciiProxyUri));
+  Status = HttpBootCheckUriScheme (AsciiUri);
+  if (EFI_ERROR (Status)) {
+if (Status == EFI_INVALID_PARAMETER) {
+  DEBUG ((DEBUG_ERROR, "Error: Invalid URI address.\n"));
+} else if (Status == EFI_ACCESS_DENIED) {
+  DEBUG ((DEBUG_ERROR, "Error: Access forbidden, only HTTPS connection is 
allowed.\n"));
 }
 
-if ((Uri[Index] >= L'A') && (Uri[Index] <= L'Z')) {
-  Uri[Index] -= (CHAR16)(L'A' - L'a');
-}
+return Status;
   }
 
-  //
-  // Only accept empty URI, or http and https URI.
-  //
-  if ((StrLen (Uri) != 0) && (StrnCmp (Uri, L"http://";, 7) != 0) && (StrnCmp 
(Uri, L"https://";, 8) != 0)) {
-return EFI_INVALID_PARAMETER;
+  Status = HttpBootCheckUriScheme (AsciiProxyUri);
+  if (EFI_ERROR (Status)) {
+if (Status == EFI_INVALID_PARAMETER) {
+  DEBUG ((DEBUG_ERROR, "Error: Invalid URI address.\n"));
+} else if (Status == EFI_ACCESS_DENIED) {
+  DEBUG ((DEBUG_ERROR, "Error: Access forbidden, only HTTPS connection is 
allowed.\n"));
+}
+
+return Status;
   }
 
   //
-  // Create a new device path by appending the IP node and URI node to
+  // Create a new device path by appending the IP node, Proxy node and URI 
node to
   // the driver's parent device path
   //
   if (!UsingIpv6) {
@@ -100,15 +112,43 @@ HttpBootAddBootOption (
 return EFI_OUT_OF_RESOURCES;
   }
 
+  //
+  // Update the Proxy node with the input Proxy URI
+  //
+  if (StrLen (ProxyUri) != 0) {
+AsciiProxyUriSize = AsciiStrSize (AsciiProxyUri);
+Length= sizeof (EFI_DEVICE_PATH_PROTOCOL) + AsciiProxyUriSize;
+Node  = AllocatePool (Length);
+if (Node == NULL) {
+  Status = EFI_OUT_OF_RESOURCES;
+  goto ON_EXIT;
+}
+
+Node->DevPath.Type= MESSAGING_DEVICE_PATH;
+Node->DevPath.SubType = MSG_URI_DP;
+SetDevicePathNodeLength (Node, Length);
+CopyMem (
+  (UINT8 *)Node + sizeof (EFI_DEVICE_PATH_PROTOCOL),
+  AsciiProxyUri,
+  AsciiProxyUriSize
+  );
+NewDevicePath = AppendDevicePathNode (TmpDevicePath, 
(EFI_DEVICE_PATH_PROTOCOL *)Node);
+FreePool (Node);
+if (NewDevicePath == NULL) {
+  Status = EFI_OUT_OF_RESOURCES;
+  goto ON_EXIT;
+}
+  } else {
+NewDevicePath = TmpDevicePath;
+  }
+
   //
   // Update the URI node with the input bo

[edk2-devel] [edk2-staging/HttpProxy PATCH v3 5/7] NetworkPkg: Add support for HTTP CONNECT Method

2022-12-02 Thread Saloni Kasbekar
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3951

Add support for the HTTP CONNECT method to request the Proxy Server
to open a tunnel to the EndPoint Server

Cc: Maciej Rabeda 
Cc: Wu Jiaxin 
Cc: Siyuan Fu 
Signed-off-by: Saloni Kasbekar 
---
 NetworkPkg/HttpBootDxe/HttpBootClient.c| 176 +
 NetworkPkg/HttpBootDxe/HttpBootClient.h|  15 ++
 NetworkPkg/HttpBootDxe/HttpBootImpl.c  |  16 +-
 NetworkPkg/HttpBootDxe/HttpBootImpl.h  |   1 +
 NetworkPkg/HttpDxe/HttpDriver.h|   2 +
 NetworkPkg/HttpDxe/HttpDxe.inf |   1 +
 NetworkPkg/HttpDxe/HttpImpl.c  | 151 ++
 NetworkPkg/Library/DxeHttpLib/DxeHttpLib.c |   5 +
 8 files changed, 335 insertions(+), 32 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c 
b/NetworkPkg/HttpBootDxe/HttpBootClient.c
index b13155b576..b4d02eaff2 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootClient.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c
@@ -905,6 +905,182 @@ HttpBootGetBootFileCallback (
   return EFI_SUCCESS;
 }
 
+/**
+  This function establishes a connection through a proxy server
+
+  @param[in]   Private The pointer to the driver's private data.
+
+  @retval EFI_SUCCESS  Connection successful.
+  @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
+  @retval Others   Unexpected error happened.
+
+**/
+EFI_STATUS
+HttpBootConnectProxy (
+  IN HTTP_BOOT_PRIVATE_DATA  *Private
+  )
+{
+  EFI_STATUS Status;
+  EFI_HTTP_STATUS_CODE   StatusCode;
+  CHAR8  *HostName;
+  EFI_HTTP_REQUEST_DATA  *RequestData;
+  HTTP_IO_RESPONSE_DATA  *ResponseData;
+  HTTP_IO*HttpIo;
+  HTTP_IO_HEADER *HttpIoHeader;
+  CHAR16 *Url;
+  CHAR16 *ProxyUrl;
+  UINTN  UrlSize;
+
+  Url  = NULL;
+  ProxyUrl = NULL;
+  RequestData  = NULL;
+  ResponseData = NULL;
+  HttpIoHeader = NULL;
+
+  UrlSize = AsciiStrSize (Private->BootFileUri);
+  Url = AllocatePool (UrlSize * sizeof (CHAR16));
+  if (Url == NULL) {
+return EFI_OUT_OF_RESOURCES;
+  }
+
+  AsciiStrToUnicodeStrS (Private->BootFileUri, Url, UrlSize);
+
+  UrlSize  = AsciiStrSize (Private->ProxyUri);
+  ProxyUrl = AllocatePool (UrlSize * (sizeof (CHAR16)));
+  if (ProxyUrl == NULL) {
+Status = EFI_OUT_OF_RESOURCES;
+goto EXIT;
+  }
+
+  AsciiStrToUnicodeStrS (Private->ProxyUri, ProxyUrl, UrlSize);
+
+  //
+  // Send HTTP request message.
+  //
+
+  //
+  // Build HTTP header for the request, 2 headers are needed to send a CONNECT 
method:
+  //   Host
+  //   User
+  //
+  HttpIoHeader = HttpIoCreateHeader (2);
+  if (HttpIoHeader == NULL) {
+Status = EFI_OUT_OF_RESOURCES;
+goto EXIT;
+  }
+
+  //
+  // Add HTTP header field 1: Host (EndPoint URI)
+  //
+  HostName = NULL;
+  Status   = HttpUrlGetHostName (
+   Private->BootFileUri,
+   Private->BootFileUriParser,
+   &HostName
+   );
+  if (EFI_ERROR (Status)) {
+goto EXIT;
+  }
+
+  Status = HttpIoSetHeader (
+ HttpIoHeader,
+ HTTP_HEADER_HOST,
+ HostName
+ );
+  if (EFI_ERROR (Status)) {
+goto EXIT;
+  }
+
+  //
+  // Add HTTP header field 2: User-Agent
+  //
+  Status = HttpIoSetHeader (
+ HttpIoHeader,
+ HTTP_HEADER_USER_AGENT,
+ HTTP_USER_AGENT_EFI_HTTP_BOOT
+ );
+  if (EFI_ERROR (Status)) {
+goto EXIT;
+  }
+
+  //
+  // Build the rest of HTTP request info.
+  //
+  RequestData = AllocatePool (sizeof (EFI_HTTP_REQUEST_DATA));
+  if (RequestData == NULL) {
+Status = EFI_OUT_OF_RESOURCES;
+goto EXIT;
+  }
+
+  RequestData->Method   = HttpMethodConnect;
+  RequestData->ProxyUrl = ProxyUrl;
+  RequestData->Url  = Url;
+
+  //
+  // Send out the request to HTTP server.
+  //
+  HttpIo = &Private->HttpIo;
+  Status = HttpIoSendRequest (
+ HttpIo,
+ RequestData,
+ HttpIoHeader->HeaderCount,
+ HttpIoHeader->Headers,
+ 0,
+ NULL
+ );
+  if (EFI_ERROR (Status)) {
+goto EXIT;
+  }
+
+  //
+  // Receive HTTP response message.
+  //
+
+  //
+  // Use zero BodyLength to only receive the response headers.
+  //
+  ResponseData = AllocateZeroPool (sizeof (HTTP_IO_RESPONSE_DATA));
+  if (ResponseData == NULL) {
+Status = EFI_OUT_OF_RESOURCES;
+goto EXIT;
+  }
+
+  Status = HttpIoRecvResponse (
+ &Private->HttpIo,
+ TRUE,
+ ResponseData
+ );
+
+  if (EFI_ERROR (Status) || EFI_ERROR (ResponseData->Status)) {
+if (EFI_ERROR (ResponseData->Status)) {
+  StatusCode = HttpIo->RspToken.Message->Data.Response->StatusCode;
+  HttpBootPrintErrorMessage (StatusCode);
+  Status = ResponseData->Status;
+}
+  }
+
+EXIT:
+  if (ResponseData != NULL) {
+FreePool (ResponseData);
+  }
+
+  if (Reque

[edk2-devel] [edk2-staging/HttpProxy PATCH v3 6/7] NetworkPkg/HttpDxe: Support HTTPS EndPoint server with Proxy

2022-12-02 Thread Saloni Kasbekar
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3951

Add support for Proxy server to connect to a HTTPS EndPoint server.
TLS Connection to be created during GET/HEAD after CONNECT method.

Cc: Maciej Rabeda 
Cc: Wu Jiaxin 
Cc: Siyuan Fu 
Signed-off-by: Saloni Kasbekar 
---
 NetworkPkg/HttpDxe/HttpImpl.c |  9 +++
 NetworkPkg/HttpDxe/HttpProto.c| 40 ++-
 NetworkPkg/HttpDxe/HttpProto.h|  8 +--
 NetworkPkg/HttpDxe/HttpsSupport.c | 16 +
 4 files changed, 46 insertions(+), 27 deletions(-)

diff --git a/NetworkPkg/HttpDxe/HttpImpl.c b/NetworkPkg/HttpDxe/HttpImpl.c
index 2a305e0864..f7d6a4c8f6 100644
--- a/NetworkPkg/HttpDxe/HttpImpl.c
+++ b/NetworkPkg/HttpDxe/HttpImpl.c
@@ -511,9 +511,10 @@ EfiHttpRequest (
   if ((HttpInstance->ConnectionClose == FALSE) &&
   (HttpInstance->RemotePort == RemotePort) &&
   (AsciiStrCmp (HttpInstance->RemoteHost, HostName) == 0) &&
-  (!HttpInstance->UseHttps || (HttpInstance->UseHttps &&
-   !TlsConfigure &&
-   (HttpInstance->TlsSessionState == 
EfiTlsSessionDataTransferring
+  (!HttpInstance->UseHttps ||
+   HttpInstance->ProxyConnected || (HttpInstance->UseHttps &&
+!TlsConfigure &&
+(HttpInstance->TlsSessionState == 
EfiTlsSessionDataTransferring
   {
 //
 // Host Name and port number of the request URL are the same with 
previous call to Request().
@@ -666,7 +667,7 @@ EfiHttpRequest (
 goto Error2;
   }
 
-  if (!Configure && !ReConfigure && !TlsConfigure) {
+  if ((!Configure && !ReConfigure) && ((HttpInstance->ProxyConnected && 
TlsConfigure) || (!TlsConfigure))) {
 //
 // For the new HTTP token, create TX TCP token events.
 //
diff --git a/NetworkPkg/HttpDxe/HttpProto.c b/NetworkPkg/HttpDxe/HttpProto.c
index 6767d90c7d..cc69401943 100644
--- a/NetworkPkg/HttpDxe/HttpProto.c
+++ b/NetworkPkg/HttpDxe/HttpProto.c
@@ -1222,6 +1222,7 @@ HttpConfigureTcp6 (
   connect one TLS session if required.
 
   @param[in]  HttpInstance   The HTTP instance private data.
+  @param[in]  TlsConfigure   The Flag indicates whether it's the new Tls 
session.
 
   @retval EFI_SUCCESSThe TCP connection is established.
   @retval EFI_NOT_READY  TCP4 protocol child is not created or 
configured.
@@ -1230,7 +1231,8 @@ HttpConfigureTcp6 (
 **/
 EFI_STATUS
 HttpConnectTcp4 (
-  IN  HTTP_PROTOCOL  *HttpInstance
+  IN  HTTP_PROTOCOL  *HttpInstance,
+  IN  BOOLEANTlsConfigure
   )
 {
   EFI_STATUS Status;
@@ -1253,16 +1255,18 @@ HttpConnectTcp4 (
 return Status;
   }
 
-  if (Tcp4State == Tcp4StateEstablished) {
+  if ((Tcp4State == Tcp4StateEstablished) && (!HttpInstance->ProxyConnected || 
!TlsConfigure)) {
 return EFI_SUCCESS;
-  } else if (Tcp4State > Tcp4StateEstablished ) {
+  } else if (Tcp4State > Tcp4StateEstablished) {
 HttpCloseConnection (HttpInstance);
   }
 
-  Status = HttpCreateConnection (HttpInstance);
-  if (EFI_ERROR (Status)) {
-DEBUG ((DEBUG_ERROR, "Tcp4 Connection fail - %x\n", Status));
-return Status;
+  if (!HttpInstance->ProxyConnected) {
+Status = HttpCreateConnection (HttpInstance);
+if (EFI_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "Tcp4 Connection fail - %x\n", Status));
+  return Status;
+}
   }
 
   //
@@ -1314,6 +1318,7 @@ HttpConnectTcp4 (
   connect one TLS session if required.
 
   @param[in]  HttpInstance   The HTTP instance private data.
+  @param[in]  TlsConfigure   The Flag indicates whether it's the new Tls 
session.
 
   @retval EFI_SUCCESSThe TCP connection is established.
   @retval EFI_NOT_READY  TCP6 protocol child is not created or 
configured.
@@ -1322,7 +1327,8 @@ HttpConnectTcp4 (
 **/
 EFI_STATUS
 HttpConnectTcp6 (
-  IN  HTTP_PROTOCOL  *HttpInstance
+  IN  HTTP_PROTOCOL  *HttpInstance,
+  IN  BOOLEANTlsConfigure
   )
 {
   EFI_STATUS Status;
@@ -1346,16 +1352,18 @@ HttpConnectTcp6 (
 return Status;
   }
 
-  if (Tcp6State == Tcp6StateEstablished) {
+  if ((Tcp6State == Tcp6StateEstablished) && (!HttpInstance->ProxyConnected || 
!TlsConfigure)) {
 return EFI_SUCCESS;
-  } else if (Tcp6State > Tcp6StateEstablished ) {
+  } else if (Tcp6State > Tcp6StateEstablished) {
 HttpCloseConnection (HttpInstance);
   }
 
-  Status = HttpCreateConnection (HttpInstance);
-  if (EFI_ERROR (Status)) {
-DEBUG ((DEBUG_ERROR, "Tcp6 Connection fail - %x\n", Status));
-return Status;
+  if (!HttpInstance->ProxyConnected) {
+Status = HttpCreateConnection (HttpInstance);
+if (EFI_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "Tcp6 Connection fail - %x\n", Status));
+  return Status;
+}
   }
 
   //
@@ -1450,7 +1458,7 @@ HttpInitSession (
 //
 // Connect TCP.
 //
-Status = Http

[edk2-devel] [edk2-staging/HttpProxy PATCH v3 4/7] NetworkPkg: Add Proxy Support to HTTP_PROTOCOL

2022-12-02 Thread Saloni Kasbekar
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3951

Update HTTP Protocol with variables to support Proxy
Use state machine to call HttpBootGetBootFile()
Add switch/case for EfiHttpRequest request method

Cc: Maciej Rabeda 
Cc: Wu Jiaxin 
Cc: Siyuan Fu 
Signed-off-by: Saloni Kasbekar 
---
 NetworkPkg/HttpBootDxe/HttpBootImpl.c | 178 +-
 NetworkPkg/HttpBootDxe/HttpBootImpl.h |   7 +
 NetworkPkg/HttpDxe/HttpImpl.c |  59 +++--
 NetworkPkg/HttpDxe/HttpProto.c|  18 ++-
 NetworkPkg/HttpDxe/HttpProto.h|   9 ++
 5 files changed, 199 insertions(+), 72 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c 
b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
index 5735b96d9e..4748de0603 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
@@ -278,6 +278,122 @@ HttpBootDhcp (
   return Status;
 }
 
+/**
+  Issue calls to HttpBootGetBootFile() based on current Boot File State
+
+  @param[in]  Private The pointer to the driver's private data.
+  @param[in, out] BufferSize  On input the size of Buffer in bytes. On 
output with a return
+  code of EFI_SUCCESS, the amount of data 
transferred to
+  Buffer. On output with a return code of 
EFI_BUFFER_TOO_SMALL,
+  the size of Buffer required to retrieve 
the requested file.
+  @param[in]  Buffer  The memory buffer to transfer the file 
to. If Buffer is NULL,
+  then the size of the requested file is 
returned in
+  BufferSize.
+  @param[out] ImageType   The image type of the downloaded file.
+
+  @retval EFI_SUCCESS  The file was loaded.
+  @retval EFI_INVALID_PARAMETERBufferSize is NULL or Buffer Size is not 
NULL but Buffer is NULL.
+  @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources
+  @retval EFI_BUFFER_TOO_SMALL The BufferSize is too small to read the 
current directory entry.
+   BufferSize has been updated with the size 
needed to complete
+   the request.
+  @retval EFI_ACCESS_DENIEDServer authentication failed.
+  @retval Others   Unexpected error happened.
+
+**/
+EFI_STATUS
+HttpBootGetBootFileCaller (
+  IN HTTP_BOOT_PRIVATE_DATA  *Private,
+  IN OUT UINTN   *BufferSize,
+  IN VOID*BufferOPTIONAL,
+  OUT HTTP_BOOT_IMAGE_TYPE   *ImageType
+  )
+{
+  HTTP_GET_BOOT_FILE_STATE  State;
+  EFI_STATUSStatus;
+
+  if (Private->BootFileSize == 0) {
+State = GetBootFileHead;
+  } else {
+State = LoadBootFile;
+  }
+
+  for ( ; ;) {
+switch (State) {
+  case GetBootFileHead:
+//
+// Try to use HTTP HEAD method.
+//
+Status = HttpBootGetBootFile (
+   Private,
+   TRUE,
+   &Private->BootFileSize,
+   NULL,
+   &Private->ImageType
+   );
+if ((EFI_ERROR (Status)) && (Status != EFI_BUFFER_TOO_SMALL)) {
+  if ((Private->AuthData != NULL) && (Status == EFI_ACCESS_DENIED)) {
+//
+// Try to use HTTP HEAD method again since the Authentication 
information is provided.
+//
+State = GetBootFileHead;
+  } else {
+State = GetBootFileGet;
+  }
+} else {
+  State = LoadBootFile;
+}
+
+break;
+
+  case GetBootFileGet:
+//
+// Failed to get file size by HEAD method, may be trunked encoding, 
try HTTP GET method.
+//
+ASSERT (Private->BootFileSize == 0);
+Status = HttpBootGetBootFile (
+   Private,
+   FALSE,
+   &Private->BootFileSize,
+   NULL,
+   &Private->ImageType
+   );
+if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
+  State = GetBootFileError;
+} else {
+  State = LoadBootFile;
+}
+
+break;
+
+  case LoadBootFile:
+if (*BufferSize < Private->BootFileSize) {
+  *BufferSize = Private->BootFileSize;
+  *ImageType  = Private->ImageType;
+  Status  = EFI_BUFFER_TOO_SMALL;
+  return Status;
+}
+
+//
+// Load the boot file into Buffer
+//
+Status = HttpBootGetBootFile (
+   Private,
+   FALSE,
+   BufferSize,
+   Buffer,
+   ImageType
+   );
+return Status;
+
+  case GetBootFileError:
+  default:
+AsciiPrint ("\n  Error: Could not retrieve NBP file size from HTTP 
server.\n");
+return Status;

[edk2-devel] [edk2-staging/HttpProxy PATCH v3 3/7] NetworkPkg/HttpBootDxe: Update HTTP Boot Driver with parsed Proxy URL

2022-12-02 Thread Saloni Kasbekar
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3951

Add ProxyUri to HTTP_BOOT_PRIVATE_DATA
Parse HTTP Boot Device path to process Proxy and EndPoint URLs

Cc: Maciej Rabeda 
Cc: Wu Jiaxin 
Cc: Siyuan Fu 
Signed-off-by: Saloni Kasbekar 
---
 NetworkPkg/HttpBootDxe/HttpBootClient.c  |  30 -
 NetworkPkg/HttpBootDxe/HttpBootDxe.h |   6 +
 NetworkPkg/HttpBootDxe/HttpBootImpl.c|  57 +
 NetworkPkg/HttpBootDxe/HttpBootSupport.c | 154 +--
 NetworkPkg/HttpBootDxe/HttpBootSupport.h |  13 +-
 5 files changed, 189 insertions(+), 71 deletions(-)

diff --git a/NetworkPkg/HttpBootDxe/HttpBootClient.c 
b/NetworkPkg/HttpBootDxe/HttpBootClient.c
index 40f64fcb6b..b13155b576 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootClient.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootClient.c
@@ -678,6 +678,10 @@ HttpBootFreeCache (
 FreePool (Cache->RequestData->Url);
   }
 
+  if (Cache->RequestData->ProxyUrl != NULL) {
+FreePool (Cache->RequestData->ProxyUrl);
+  }
+
   FreePool (Cache->RequestData);
 }
 
@@ -950,6 +954,7 @@ HttpBootGetBootFile (
   UINT8*Block;
   UINTNUrlSize;
   CHAR16   *Url;
+  CHAR16   *ProxyUrl;
   BOOLEAN  IdentityMode;
   UINTNReceivedSize;
   CHAR8BaseAuthValue[80];
@@ -989,6 +994,22 @@ HttpBootGetBootFile (
   // Not found in cache, try to download it through HTTP.
   //
 
+  //
+  // Initialize ProxyUrl - Set to NULL if connecting without Proxy
+  //
+  if (Private->ProxyUri != NULL) {
+UrlSize  = AsciiStrSize (Private->ProxyUri);
+ProxyUrl = AllocatePool (UrlSize * (sizeof (CHAR16)));
+if (ProxyUrl == NULL) {
+  Status = EFI_OUT_OF_RESOURCES;
+  goto ERROR_1;
+}
+
+AsciiStrToUnicodeStrS (Private->ProxyUri, ProxyUrl, UrlSize);
+  } else {
+ProxyUrl = NULL;
+  }
+
   //
   // 1. Create a temp cache item for the requested URI if caller doesn't 
provide buffer.
   //
@@ -1106,8 +1127,9 @@ HttpBootGetBootFile (
 goto ERROR_3;
   }
 
-  RequestData->Method = HeaderOnly ? HttpMethodHead : HttpMethodGet;
-  RequestData->Url= Url;
+  RequestData->Method   = HeaderOnly ? HttpMethodHead : HttpMethodGet;
+  RequestData->Url  = Url;
+  RequestData->ProxyUrl = ProxyUrl;
 
   //
   // 2.3 Record the request info in a temp cache item.
@@ -1441,6 +1463,10 @@ ERROR_2:
   }
 
 ERROR_1:
+  if (ProxyUrl != NULL) {
+FreePool (ProxyUrl);
+  }
+
   if (Url != NULL) {
 FreePool (Url);
   }
diff --git a/NetworkPkg/HttpBootDxe/HttpBootDxe.h 
b/NetworkPkg/HttpBootDxe/HttpBootDxe.h
index 5ff8ad4698..8caf2e9a45 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootDxe.h
+++ b/NetworkPkg/HttpBootDxe/HttpBootDxe.h
@@ -223,6 +223,12 @@ struct _HTTP_BOOT_PRIVATE_DATA {
   CHAR8*FilePathUri;
   VOID *FilePathUriParser;
 
+  //
+  // URI string for the Proxy host if BootFileUri contains a Proxy
+  // URI in the path
+  //
+  CHAR8*ProxyUri;
+
   //
   // Cached HTTP data
   //
diff --git a/NetworkPkg/HttpBootDxe/HttpBootImpl.c 
b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
index b4c61925b9..5735b96d9e 100644
--- a/NetworkPkg/HttpBootDxe/HttpBootImpl.c
+++ b/NetworkPkg/HttpBootDxe/HttpBootImpl.c
@@ -115,19 +115,21 @@ HttpBootStart (
 {
   UINTN   Index;
   EFI_STATUS  Status;
-  CHAR8   *Uri;
+  CHAR8   *ProxyUri;
+  CHAR8   *EndPointUri;
 
-  Uri = NULL;
+  ProxyUri= NULL;
+  EndPointUri = NULL;
 
   if ((Private == NULL) || (FilePath == NULL)) {
 return EFI_INVALID_PARAMETER;
   }
 
   //
-  // Check the URI in the input FilePath, in order to see whether it is
+  // Check the URIs in the input FilePath, in order to see whether it is
   // required to boot from a new specified boot file.
   //
-  Status = HttpBootParseFilePath (FilePath, &Uri);
+  Status = HttpBootParseFilePath (FilePath, &ProxyUri, &EndPointUri);
   if (EFI_ERROR (Status)) {
 return EFI_INVALID_PARAMETER;
   }
@@ -143,28 +145,21 @@ HttpBootStart (
 // recorded before.
 //
 if ((UsingIpv6 != Private->UsingIpv6) ||
-((Uri != NULL) && (AsciiStrCmp (Private->BootFileUri, Uri) != 0)))
+((EndPointUri != NULL) && (AsciiStrCmp (Private->BootFileUri, 
EndPointUri) != 0)))
 {
   //
   // Restart is required, first stop then continue this start function.
   //
   Status = HttpBootStop (Private);
   if (EFI_ERROR (Status)) {
-if (Uri != NULL) {
-  FreePool (Uri);
-}
-
-return Status;
+goto ERROR;
   }
 } else {
   //
   // Restart is not required.
   //
-  if (Uri != NULL) {
-FreePool (Uri);
-  }
-
-  return EFI_ALREADY_STARTED;
+  Status = EFI_ALREADY_STARTED;
+  goto ERROR;
 }
   }
 
@@ -176,17 +171,16 @@ HttpBootStart (
   } else if (!UsingIpv6 && (Private->Ip4Ni

[edk2-devel] [edk2-staging/HttpProxy PATCH v3 2/7] MdePkg/Include: Add Proxy Server URL in EFI_HTTP_REQUEST_DATA

2022-12-02 Thread Saloni Kasbekar
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3951

Add Proxy Server URL to EFI_HTTP_REQUEST_DATA.
This will be used when a Proxy Server URL is a part of the
HTTP Boot device path.

Cc: Zhiguang Liu 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Maciej Rabeda 
Signed-off-by: Saloni Kasbekar 
---
 MdePkg/Include/Protocol/Http.h | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/Protocol/Http.h b/MdePkg/Include/Protocol/Http.h
index 28e6221593..9ee08baa14 100644
--- a/MdePkg/Include/Protocol/Http.h
+++ b/MdePkg/Include/Protocol/Http.h
@@ -188,9 +188,17 @@ typedef struct {
   /// The URI of a remote host. From the information in this field, the HTTP 
instance
   /// will be able to determine whether to use HTTP or HTTPS and will also be 
able to
   /// determine the port number to use. If no port number is specified, port 
80 (HTTP)
-  /// is assumed. See RFC 3986 for more details on URI syntax.
+  /// or 443 (HTTPS) is assumed. See RFC 3986 for more details on URI syntax.
   ///
   CHAR16 *Url;
+  ///
+  /// The URI of an Proxy Host. This field will be NULL if there is no Proxy 
Host
+  /// in the device path. From the information in this field, the HTTP 
instance will
+  /// be able to determine whether to use HTTP or HTTPS and will also be able 
to
+  /// determine the port number to use. If no port number is specified, port 
80 (HTTP)
+  /// or 443 (HTTPS) is assumed. See RFC 3986 for more details on URI syntax.
+  ///
+  CHAR16 *ProxyUrl;
 } EFI_HTTP_REQUEST_DATA;
 
 ///
-- 
2.36.1.windows.1



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




[edk2-devel] [edk2-staging/HttpProxy PATCH v3 1/7] MdeModulePkg/Library: Support multi-URI HTTP Boot device path

2022-12-02 Thread Saloni Kasbekar
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3951

Process device path with proxy server and endpoint server included.
Update comment for sample HTTP Boot device path.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Maciej Rabeda 
Signed-off-by: Saloni Kasbekar 
---
 .../Library/UefiBootManagerLib/BmBoot.c   | 28 +++
 .../UefiBootManagerLib/BmBootDescription.c|  4 +--
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 962892d38f..fdef1ba292 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1513,6 +1513,9 @@ BmExpandLoadFiles (
   UINTN HandleCount;
   UINTN Index;
   EFI_DEVICE_PATH_PROTOCOL  *Node;
+  URI_DEVICE_PATH   *NullUriPath;
+
+  NullUriPath = NULL;
 
   //
   // Get file buffer from load file instance.
@@ -1545,11 +1548,36 @@ BmExpandLoadFiles (
 
 for (Index = 0; Index < HandleCount; Index++) {
   if (BmMatchHttpBootDevicePath (DevicePathFromHandle (Handles[Index]), 
FilePath)) {
+//
+// Matches HTTP Boot Device Path described as
+//   
../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)]/Uri(...)
+//   
../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]/Uri(...)
+//
+Handle = Handles[Index];
+goto Done;
+  }
+}
+
+NullUriPath = (URI_DEVICE_PATH *)CreateDeviceNode (
+   MESSAGING_DEVICE_PATH,
+   MSG_URI_DP,
+   (UINT16)(sizeof (URI_DEVICE_PATH))
+   );
+for (Index = 0; Index < HandleCount; Index++) {
+  if (BmMatchHttpBootDevicePath (AppendDevicePathNode 
(DevicePathFromHandle (Handles[Index]), (EFI_DEVICE_PATH_PROTOCOL 
*)NullUriPath), FilePath)) {
+//
+// Matches HTTP Boot Device Path described as
+//   
../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)]/Uri(...)/Uri(...)
+//   
../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]/Uri(...)/Uri(...)
+//
 Handle = Handles[Index];
 break;
   }
 }
 
+FreePool (NullUriPath);
+
+Done:
 if (Handles != NULL) {
   FreePool (Handles);
 }
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
index fac33b9ee9..108efd8096 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBootDescription.c
@@ -412,8 +412,8 @@ BmGetNetworkDescription (
   //   ../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)
   //
   // The HTTP device path is like:
-  //   ../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)]/Uri(...)
-  //   ../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)]/Uri(...)
+  //   
../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv4(...)[/Dns(...)][/Uri(...)]/Uri(...)
+  //   
../Mac(...)[/Vlan(...)][/Wi-Fi(...)]/IPv6(...)[/Dns(...)][/Uri(...)]/Uri(...)
   //
   while (!IsDevicePathEnd (DevicePath) &&
  ((DevicePathType (DevicePath) != MESSAGING_DEVICE_PATH) ||
-- 
2.36.1.windows.1



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




[edk2-devel] [edk2-staging/HttpProxy PATCH v3 0/7] Support HTTPS Proxy Server for HTTP Boot

2022-12-02 Thread Saloni Kasbekar
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3951
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4052

- Add CONNECT HTTP Method to create a tunnel through the Proxy Server
- TLS adjustments to establish handshake with the Endpoint Server
- Use multi-URI device path to support Proxy Server URI as a 
  part of the Http Boot Device Path
- Add Proxy URI field in the setup menu

Saloni Kasbekar (7):
  MdeModulePkg/Library: Support multi-URI HTTP Boot device path
  MdePkg/Include: Add Proxy Server URL in EFI_HTTP_REQUEST_DATA
  NetworkPkg/HttpBootDxe: Update HTTP Boot Driver with parsed Proxy URL
  NetworkPkg: Add Proxy Support to HTTP_PROTOCOL
  NetworkPkg: Add support for HTTP CONNECT Method
  NetworkPkg/HttpDxe: Support HTTPS EndPoint server with Proxy
  NetworkPkg/HttpBootDxe: Add Proxy URI input in setup menu

 .../Library/UefiBootManagerLib/BmBoot.c   |  28 ++
 .../UefiBootManagerLib/BmBootDescription.c|   4 +-
 MdePkg/Include/Protocol/Http.h|  10 +-
 NetworkPkg/HttpBootDxe/HttpBootClient.c   | 206 ++-
 NetworkPkg/HttpBootDxe/HttpBootClient.h   |  15 ++
 NetworkPkg/HttpBootDxe/HttpBootConfig.c   |  99 +--
 .../HttpBootDxe/HttpBootConfigNVDataStruc.h   |   4 +-
 .../HttpBootDxe/HttpBootConfigStrings.uni |   2 +
 NetworkPkg/HttpBootDxe/HttpBootConfigVfr.vfr  |   9 +
 NetworkPkg/HttpBootDxe/HttpBootDxe.h  |   6 +
 NetworkPkg/HttpBootDxe/HttpBootImpl.c | 249 --
 NetworkPkg/HttpBootDxe/HttpBootImpl.h |   8 +
 NetworkPkg/HttpBootDxe/HttpBootSupport.c  | 154 ---
 NetworkPkg/HttpBootDxe/HttpBootSupport.h  |  13 +-
 NetworkPkg/HttpDxe/HttpDriver.h   |   2 +
 NetworkPkg/HttpDxe/HttpDxe.inf|   1 +
 NetworkPkg/HttpDxe/HttpImpl.c | 215 +++
 NetworkPkg/HttpDxe/HttpProto.c|  58 ++--
 NetworkPkg/HttpDxe/HttpProto.h|  17 +-
 NetworkPkg/HttpDxe/HttpsSupport.c |  16 +-
 NetworkPkg/Library/DxeHttpLib/DxeHttpLib.c|   5 +
 21 files changed, 893 insertions(+), 228 deletions(-)

-- 
2.36.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96916): https://edk2.groups.io/g/devel/message/96916
Mute This Topic: https://groups.io/mt/95413290/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/4] MdeModulePkg/XhciDxe/XhciReg: Handle incorrect PSIV indices

2022-12-02 Thread Sean Rhodes
Hi Hao

They are now resolved

Thanks

Sean

On Fri, 2 Dec 2022 at 06:25, Wu, Hao A  wrote:

> Hello,
>
> I saw there are several CI check failures for this 4 patches:
> https://github.com/tianocore/edk2/pull/3702
>
> Could you help to resolve them? Thanks.
>
> Best Regards,
> Hao Wu
>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Sean
> > Rhodes
> > Sent: Friday, December 2, 2022 4:25 AM
> > To: devel@edk2.groups.io
> > Cc: Matt DeVillier ; Wu, Hao A
> > ; Ni, Ray ; Rhodes, Sean
> > 
> > Subject: [edk2-devel] [PATCH 1/4] MdeModulePkg/XhciDxe/XhciReg: Handle
> > incorrect PSIV indices
> >
> > From: Matt DeVillier 
> >
> > On some platforms, including Sky Lake and Kaby Lake, the PSIV (Protocol
> Speed
> > ID Value) indicesare shared between Protocol Speed ID DWORD' in the
> > extended capabilities registers for both USB2 (Full Speed) and USB3
> (Super
> > Speed).
> >
> > An example can be found below:
> >
> > XhcCheckUsbPortSpeedUsedPsic: checking for USB2 ext caps
> > XhciPsivGetPsid: found 3 PSID entries
> > XhciPsivGetPsid: looking for port speed 1
> > XhciPsivGetPsid: PSIV 1 PSIE 2 PLT 0 PSIM 12
> > XhciPsivGetPsid: PSIV 2 PSIE 1 PLT 0 PSIM 1500
> > XhciPsivGetPsid: PSIV 3 PSIE 2 PLT 0 PSIM 480
> > XhcCheckUsbPortSpeedUsedPsic: checking for USB3 ext caps
> > XhciPsivGetPsid: found 3 PSID entries
> > XhciPsivGetPsid: looking for port speed 1
> > XhciPsivGetPsid: PSIV 1 PSIE 3 PLT 0 PSIM 5
> > XhciPsivGetPsid: PSIV 2 PSIE 3 PLT 0 PSIM 10
> > XhciPsivGetPsid: PSIV 34 PSIE 2 PLT 0 PSIM 1248
> >
> > The result is edk2 detecting USB2 devices as USB3 devices, which
> consequently
> > causes enumeration to fail.
> >
> > To avoid incorrect detection, check the extended capability registers
> for USB2
> > before USB3. If edk2 finds a match for a USB 2 device, don't check for
> USB 3.
> >
> > Cc: Hao A Wu 
> > Cc: Ray Ni 
> > Reviewed-by: Sean Rhodes 
> > Signed-off-by: Matt DeVillier 
> > Change-Id: I5bcf32105ce85fda95b4ba98a5e420e8f522374c
> > ---
> >  MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c | 36 +++---
> > MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h |  1 +
> >  2 files changed, 22 insertions(+), 15 deletions(-)
> >
> > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
> > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
> > index 2b4a4b2444..c992323443 100644
> > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
> > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c
> > @@ -698,25 +698,11 @@ XhcCheckUsbPortSpeedUsedPsic (
> >SpField.Dword = 0;   UsbSpeedIdMap = 0; -  //-  // Check xHCI
> Supported
> > Protocol Capability, find the PSIV field to match-  // PortSpeed
> definition when
> > the Major Revision is 03h.-  //-  if (Xhc->Usb3SupOffset != 0x)
> {-
> > SpField.Dword = XhciPsivGetPsid (Xhc, Xhc->Usb3SupOffset, PortSpeed);-
>   if
> > (SpField.Dword != 0) {-  //-  // Found the corresponding PORTSC
> value in
> > PSIV field of USB3 offset.-  //-  UsbSpeedIdMap =
> > USB_PORT_STAT_SUPER_SPEED;-}-  }-   //   // Check xHCI Supported
> Protocol
> > Capability, find the PSIV field to match   // PortSpeed definition when
> the Major
> > Revision is 02h.   //-  if ((UsbSpeedIdMap == 0) && (Xhc->Usb2SupOffset
> !=
> > 0x)) {+  if (Xhc->Usb2SupOffset != 0x) {
>  SpField.Dword =
> > XhciPsivGetPsid (Xhc, Xhc->Usb2SupOffset, PortSpeed); if
> (SpField.Dword != 0)
> > {   //@@ -733,6 +719,12 @@ XhcCheckUsbPortSpeedUsedPsic (
> >// PSIM shows as default High-speed protocol, apply to
> High-speed
> > mapping   //   UsbSpeedIdMap =
> > USB_PORT_STAT_HIGH_SPEED;+} else if (SpField.Data.Psim ==
> > XHC_SUPPORTED_PROTOCOL_USB2_FULL_SPEED_PSIM) {+  //+  //
> > PSIM shows as default Full-speed protocol, return 0+  // to
> ensure no port
> > status set+  //+  return 0; }   } else if
> (SpField.Data.Psie == 1)
> > { //@@ -750,6 +742,20 @@ XhcCheckUsbPortSpeedUsedPsic (
> >  }   } +  //+  // Check xHCI Supported Protocol Capability, find the
> PSIV field to
> > match+  // PortSpeed definition when the Major Revision is 03h.+  //+  if
> > ((UsbSpeedIdMap == 0) && (Xhc->Usb3SupOffset != 0x)) {+
> > SpField.Dword = XhciPsivGetPsid (Xhc, Xhc->Usb3SupOffset, PortSpeed);+
>   if
> > (SpField.Dword != 0) {+  //+  // Found the corresponding PORTSC
> value in
> > PSIV field of USB3 offset.+  //+  UsbSpeedIdMap =
> > USB_PORT_STAT_SUPER_SPEED;+}+  }+   return UsbSpeedIdMap; } diff
> --git
> > a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
> > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
> > index 5fe2ba4f0e..74ac6297ba 100644
> > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
> > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.h
> > @@ -85,6 +85,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> >  #define XHC_SUPPORTED_PROTOCOL_DW2_OFFSET   0x08 #define
> > XHC_SUPPORTED_PROTOCOL_PSI_OFFSET

Re: [edk2-devel] [PATCH 1/1] MdeModulePkg: Put USB DEBUGs that occur for bulk timeouts under VERBOSE

2022-12-02 Thread Rebecca Cran

On 12/1/22 18:26, Wu, Hao A wrote:

Sorry for a question.

For the changes in EhcBulkTransfer() and XhcBulkTransfer(), is it feasible
to distinguish timeout cases with other error cases and only adjust
timeout related messages to VERBOSE level?



No problem!
Something like this?

  if (EFI_ERROR (Status)) {
if (Status == EFI_TIMEOUT) {
  DebugErrorLevel = DEBUG_VERBOSE;
} else {
  DebugErrorLevel = DEBUG_ERROR;
}

DEBUG ((DebugErrorLevel, "XhcBulkTransfer: error - %r, transfer - 
%x\n", Status, *TransferResult));

  }

I'll send out a v2 patch.

--
Rebecca Cran


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




[edk2-devel] [PATCH 14/14] OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + mQemuFwCfgDmaSupported

2022-12-02 Thread Gerd Hoffmann
Remove global variables, store the state in PlatformInfoHob instead.
Probing for fw_cfg happens on first use, at library initialization
time the Hob might not be present yet.

Signed-off-by: Gerd Hoffmann 
---
 .../Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf  |  4 ++
 OvmfPkg/Include/Library/PlatformInitLib.h |  4 ++
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c   | 44 ---
 3 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf 
b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
index 1d7543a7d40f..b1f548febcf7 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
@@ -39,8 +39,12 @@ [LibraryClasses]
   BaseLib
   BaseMemoryLib
   DebugLib
+  HobLib
   IoLib
   MemoryAllocationLib
 
+[Guids]
+  gUefiOvmfPkgPlatformInfoGuid
+
 [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase
diff --git a/OvmfPkg/Include/Library/PlatformInitLib.h 
b/OvmfPkg/Include/Library/PlatformInitLib.h
index da7ed76041d2..bf6f90a5761c 100644
--- a/OvmfPkg/Include/Library/PlatformInitLib.h
+++ b/OvmfPkg/Include/Library/PlatformInitLib.h
@@ -50,6 +50,10 @@ typedef struct {
   UINT32   S3AcpiReservedMemorySize;
 
   UINT64   FeatureControlValue;
+
+  BOOLEAN  QemuFwCfgChecked;
+  BOOLEAN  QemuFwCfgSupported;
+  BOOLEAN  QemuFwCfgDmaSupported;
 } EFI_HOB_PLATFORM_INFO;
 #pragma pack()
 
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c 
b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c
index a936fd103955..da86a3c84c02 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c
@@ -9,17 +9,17 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 
+#include 
 #include 
-#include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 
 #include "QemuFwCfgLibInternal.h"
 
-STATIC BOOLEAN  mQemuFwCfgSupported = FALSE;
-STATIC BOOLEAN  mQemuFwCfgDmaSupported;
-
 /**
   Check if it is Tdx guest
 
@@ -93,13 +93,39 @@ QemuFwCfgProbe (
 ));
 }
 
+STATIC
+EFI_HOB_PLATFORM_INFO *
+QemuFwCfgGetPlatformInfo (
+  VOID
+  )
+{
+  EFI_HOB_PLATFORM_INFO  *PlatformInfoHob;
+  EFI_HOB_GUID_TYPE  *GuidHob;
+
+  GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid);
+  if (GuidHob == NULL) {
+return NULL;
+  }
+
+  PlatformInfoHob = (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob);
+
+  if (!PlatformInfoHob->QemuFwCfgChecked) {
+QemuFwCfgProbe (
+  &PlatformInfoHob->QemuFwCfgSupported,
+  &PlatformInfoHob->QemuFwCfgDmaSupported
+  );
+PlatformInfoHob->QemuFwCfgChecked = TRUE;
+  }
+
+  return PlatformInfoHob;
+}
+
 RETURN_STATUS
 EFIAPI
 QemuFwCfgInitialize (
   VOID
   )
 {
-  QemuFwCfgProbe (&mQemuFwCfgSupported, &mQemuFwCfgDmaSupported);
   return RETURN_SUCCESS;
 }
 
@@ -117,7 +143,9 @@ InternalQemuFwCfgIsAvailable (
   VOID
   )
 {
-  return mQemuFwCfgSupported;
+  EFI_HOB_PLATFORM_INFO  *PlatformInfoHob = QemuFwCfgGetPlatformInfo ();
+
+  return PlatformInfoHob->QemuFwCfgSupported;
 }
 
 /**
@@ -132,7 +160,9 @@ InternalQemuFwCfgDmaIsAvailable (
   VOID
   )
 {
-  return mQemuFwCfgDmaSupported;
+  EFI_HOB_PLATFORM_INFO  *PlatformInfoHob = QemuFwCfgGetPlatformInfo ();
+
+  return PlatformInfoHob->QemuFwCfgDmaSupported;
 }
 
 /**
-- 
2.38.1



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




[edk2-devel] [PATCH 13/14] OvmfPkg/QemuFwCfgLib: rewrite fw_cfg probe

2022-12-02 Thread Gerd Hoffmann
Move the code to a new QemuFwCfgProbe() function.  Use direct Io*() calls
instead of indirect QemuFwCfg*() calls to make sure we don't get
recursive calls.  Also simplify CC guest detection.

Signed-off-by: Gerd Hoffmann 
---
 .../Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf  |   1 -
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c   | 101 +++---
 2 files changed, 41 insertions(+), 61 deletions(-)

diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf 
b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
index 3910511880c9..1d7543a7d40f 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf
@@ -41,7 +41,6 @@ [LibraryClasses]
   DebugLib
   IoLib
   MemoryAllocationLib
-  MemEncryptSevLib
 
 [Pcd]
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase
diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c 
b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c
index 7ab7027af168..a936fd103955 100644
--- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c
+++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c
@@ -13,7 +13,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "QemuFwCfgLibInternal.h"
@@ -27,15 +26,16 @@ STATIC BOOLEAN  mQemuFwCfgDmaSupported;
   @retvalTRUE   It is Tdx guest
   @retvalFALSE  It is not Tdx guest
 **/
+STATIC
 BOOLEAN
-QemuFwCfgIsTdxGuest (
+QemuFwCfgIsCcGuest (
   VOID
   )
 {
   CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER  *CcWorkAreaHeader;
 
   CcWorkAreaHeader = (CONFIDENTIAL_COMPUTING_WORK_AREA_HEADER *)FixedPcdGet32 
(PcdOvmfWorkAreaBase);
-  return (CcWorkAreaHeader != NULL && CcWorkAreaHeader->GuestType == 
CcGuestTypeIntelTdx);
+  return (CcWorkAreaHeader != NULL && CcWorkAreaHeader->GuestType != 
CcGuestTypeNonEncrypted);
 }
 
 /**
@@ -57,62 +57,49 @@ QemuFwCfgIsAvailable (
   return InternalQemuFwCfgIsAvailable ();
 }
 
+STATIC
+VOID
+QemuFwCfgProbe (
+  BOOLEAN  *Supported,
+  BOOLEAN  *DmaSupported
+  )
+{
+  UINT32   Signature;
+  UINT32   Revision;
+  BOOLEAN  CcGuest;
+
+  // Use direct Io* calls for probing to avoid recursion.
+  IoWrite16 (FW_CFG_IO_SELECTOR, (UINT16)QemuFwCfgItemSignature);
+  IoReadFifo8 (FW_CFG_IO_DATA, sizeof Signature, &Signature);
+  IoWrite16 (FW_CFG_IO_SELECTOR, (UINT16)QemuFwCfgItemInterfaceVersion);
+  IoReadFifo8 (FW_CFG_IO_DATA, sizeof Revision, &Revision);
+  CcGuest = QemuFwCfgIsCcGuest ();
+
+  *Supported= FALSE;
+  *DmaSupported = FALSE;
+  if ((Signature == SIGNATURE_32 ('Q', 'E', 'M', 'U')) && (Revision >= 1)) {
+*Supported = TRUE;
+if ((Revision & FW_CFG_F_DMA) && !CcGuest) {
+  *DmaSupported = TRUE;
+}
+  }
+
+  DEBUG ((
+DEBUG_INFO,
+"%a: Supported %d, DMA %d\n",
+__func__,
+*Supported,
+*DmaSupported
+));
+}
+
 RETURN_STATUS
 EFIAPI
 QemuFwCfgInitialize (
   VOID
   )
 {
-  UINT32  Signature;
-  UINT32  Revision;
-
-  //
-  // Enable the access routines while probing to see if it is supported.
-  // For probing we always use the IO Port (IoReadFifo8()) access method.
-  //
-  mQemuFwCfgSupported= TRUE;
-  mQemuFwCfgDmaSupported = FALSE;
-
-  QemuFwCfgSelectItem (QemuFwCfgItemSignature);
-  Signature = QemuFwCfgRead32 ();
-  DEBUG ((DEBUG_INFO, "FW CFG Signature: 0x%x\n", Signature));
-  QemuFwCfgSelectItem (QemuFwCfgItemInterfaceVersion);
-  Revision = QemuFwCfgRead32 ();
-  DEBUG ((DEBUG_INFO, "FW CFG Revision: 0x%x\n", Revision));
-  if ((Signature != SIGNATURE_32 ('Q', 'E', 'M', 'U')) ||
-  (Revision < 1)
-  )
-  {
-DEBUG ((DEBUG_INFO, "QemuFwCfg interface not supported.\n"));
-mQemuFwCfgSupported = FALSE;
-return RETURN_SUCCESS;
-  }
-
-  if ((Revision & FW_CFG_F_DMA) == 0) {
-DEBUG ((DEBUG_INFO, "QemuFwCfg interface (IO Port) is supported.\n"));
-  } else {
-//
-// If SEV is enabled then we do not support DMA operations in PEI phase.
-// This is mainly because DMA in SEV guest requires using bounce buffer
-// (which need to allocate dynamic memory and allocating a PAGE size'd
-// buffer can be challenge in PEI phase)
-//
-if (MemEncryptSevIsEnabled ()) {
-  DEBUG ((DEBUG_INFO, "SEV: QemuFwCfg fallback to IO Port interface.\n"));
-} else if (QemuFwCfgIsTdxGuest ()) {
-  //
-  // If TDX is enabled then we do not support DMA operations in PEI phase.
-  // This is mainly because DMA in TDX guest requires using bounce buffer
-  // (which need to allocate dynamic memory and allocating a PAGE size'd
-  // buffer can be challenge in PEI phase)
-  //
-  DEBUG ((DEBUG_INFO, "TDX: QemuFwCfg fallback to IO Port interface.\n"));
-} else {
-  mQemuFwCfgDmaSupported = TRUE;
-  DEBUG ((DEBUG_INFO, "QemuFwCfg interface (DMA) is supported.\n"));
-}
-  }
-
+  QemuFwCfgProbe (&mQemuFwCfgSupported, &mQemuFwCfgDmaSupported);
   return RETURN_SUCCESS;
 }
 
@@ -183,17 +170,11 @@ InternalQemuFwCfgDmaBytes (
 return;
   }
 
-  //
-  // SEV does not support DMA operations in PEI stage, we should
-  // not have reached h

[edk2-devel] [PATCH 12/14] OvmfPkg/DebugLibIoPort: use Rom version for PEI

2022-12-02 Thread Gerd Hoffmann
This variant does not use global variables.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc  | 4 ++--
 OvmfPkg/Bhyve/BhyveX64.dsc| 4 ++--
 OvmfPkg/Microvm/MicrovmX64.dsc| 4 ++--
 OvmfPkg/OvmfPkgIa32.dsc   | 4 ++--
 OvmfPkg/OvmfPkgIa32X64.dsc| 4 ++--
 OvmfPkg/OvmfPkgX64.dsc| 4 ++--
 .../PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf  | 2 +-
 7 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index 8f7cae787e97..cf051c83165e 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -244,7 +244,7 @@ [LibraryClasses.common.PEI_CORE]
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
 !else
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
 !endif
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
 
@@ -260,7 +260,7 @@ [LibraryClasses.common.PEIM]
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
 !else
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
 !endif
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
   
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index e3bb367b6bf6..befec670d4f3 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -265,7 +265,7 @@ [LibraryClasses.common.PEI_CORE]
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
 !else
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
 !endif
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
 
@@ -281,7 +281,7 @@ [LibraryClasses.common.PEIM]
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
 !else
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
 !endif
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
   
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 994a02d30107..583e0cd12dc0 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -292,7 +292,7 @@ [LibraryClasses.common.PEI_CORE]
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
 !else
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
 !endif
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
 
@@ -308,7 +308,7 @@ [LibraryClasses.common.PEIM]
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
 !else
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
 !endif
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
   
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 6f774baf90f5..23ed6fb2b659 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -294,7 +294,7 @@ [LibraryClasses.common.PEI_CORE]
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
 !else
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
 !endif
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
 
@@ -310,7 +310,7 @@ [LibraryClasses.common.PEIM]
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
 !else
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
 !endif
   PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
   
ResourcePublicationLib|MdePkg/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index c851764dec05..6ed5eadd163d

[edk2-devel] [PATCH 11/14] OvmfPkg/PlatformPei: remove mFeatureControlValue

2022-12-02 Thread Gerd Hoffmann
Use PlatformInfoHob->FeatureControlValue instead.
OnMpServicesAvailable() will find PlatformInfoHob using
GetFirstGuidHob() and pass a pointer to the WriteFeatureControl
callback.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/Include/Library/PlatformInitLib.h |  2 ++
 OvmfPkg/PlatformPei/Platform.h|  2 +-
 OvmfPkg/PlatformPei/FeatureControl.c  | 44 ---
 OvmfPkg/PlatformPei/Platform.c|  2 +-
 4 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/OvmfPkg/Include/Library/PlatformInitLib.h 
b/OvmfPkg/Include/Library/PlatformInitLib.h
index c5234bf26d45..da7ed76041d2 100644
--- a/OvmfPkg/Include/Library/PlatformInitLib.h
+++ b/OvmfPkg/Include/Library/PlatformInitLib.h
@@ -48,6 +48,8 @@ typedef struct {
 
   UINT32   S3AcpiReservedMemoryBase;
   UINT32   S3AcpiReservedMemorySize;
+
+  UINT64   FeatureControlValue;
 } EFI_HOB_PLATFORM_INFO;
 #pragma pack()
 
diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index 86f603ff649c..1cf44844a781 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -70,7 +70,7 @@ MemTypeInfoInitialization (
 
 VOID
 InstallFeatureControlCallback (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   );
 
 VOID
diff --git a/OvmfPkg/PlatformPei/FeatureControl.c 
b/OvmfPkg/PlatformPei/FeatureControl.c
index 5864ee0c214d..d8a398cd5565 100644
--- a/OvmfPkg/PlatformPei/FeatureControl.c
+++ b/OvmfPkg/PlatformPei/FeatureControl.c
@@ -8,6 +8,7 @@
 **/
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -16,11 +17,6 @@
 
 #include "Platform.h"
 
-//
-// The value to be written to the Feature Control MSR, retrieved from fw_cfg.
-//
-STATIC UINT64  mFeatureControlValue;
-
 /**
   Write the Feature Control MSR on an Application Processor or the Boot
   Processor.
@@ -38,10 +34,22 @@ WriteFeatureControl (
   IN OUT VOID  *WorkSpace
   )
 {
+  EFI_HOB_PLATFORM_INFO  *PlatformInfoHob = WorkSpace;
+
   if (TdIsEnabled ()) {
-TdVmCall (TDVMCALL_WRMSR, (UINT64)MSR_IA32_FEATURE_CONTROL, 
mFeatureControlValue, 0, 0, 0);
+TdVmCall (
+  TDVMCALL_WRMSR,
+  (UINT64)MSR_IA32_FEATURE_CONTROL,
+  PlatformInfoHob->FeatureControlValue,
+  0,
+  0,
+  0
+  );
   } else {
-AsmWriteMsr64 (MSR_IA32_FEATURE_CONTROL, mFeatureControlValue);
+AsmWriteMsr64 (
+  MSR_IA32_FEATURE_CONTROL,
+  PlatformInfoHob->FeatureControlValue
+  );
   }
 }
 
@@ -67,6 +75,15 @@ OnMpServicesAvailable (
 {
   EFI_PEI_MP_SERVICES_PPI  *MpServices;
   EFI_STATUS   Status;
+  EFI_HOB_PLATFORM_INFO*PlatformInfoHob;
+  EFI_HOB_GUID_TYPE*GuidHob;
+
+  GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid);
+  if (GuidHob == NULL) {
+return EFI_UNSUPPORTED;
+  }
+
+  PlatformInfoHob = (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob);
 
   DEBUG ((DEBUG_VERBOSE, "%a: %a\n", gEfiCallerBaseName, __FUNCTION__));
 
@@ -80,7 +97,7 @@ OnMpServicesAvailable (
  WriteFeatureControl, // Procedure
  FALSE,   // SingleThread
  0,   // TimeoutInMicroSeconds: 
inf.
- NULL // ProcedureArgument
+ PlatformInfoHob  // ProcedureArgument
  );
   if (EFI_ERROR (Status) && (Status != EFI_NOT_STARTED)) {
 DEBUG ((DEBUG_ERROR, "%a: StartupAllAps(): %r\n", __FUNCTION__, Status));
@@ -90,7 +107,7 @@ OnMpServicesAvailable (
   //
   // Now write the MSR on the BSP too.
   //
-  WriteFeatureControl (NULL);
+  WriteFeatureControl (PlatformInfoHob);
   return EFI_SUCCESS;
 }
 
@@ -107,7 +124,7 @@ STATIC CONST EFI_PEI_NOTIFY_DESCRIPTOR  mMpServicesNotify = 
{
 
 VOID
 InstallFeatureControlCallback (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   EFI_STATUSStatus;
@@ -119,7 +136,7 @@ InstallFeatureControlCallback (
  &FwCfgItem,
  &FwCfgSize
  );
-  if (EFI_ERROR (Status) || (FwCfgSize != sizeof mFeatureControlValue)) {
+  if (EFI_ERROR (Status) || (FwCfgSize != sizeof 
(PlatformInfoHob->FeatureControlValue))) {
 //
 // Nothing to do.
 //
@@ -127,7 +144,10 @@ InstallFeatureControlCallback (
   }
 
   QemuFwCfgSelectItem (FwCfgItem);
-  QemuFwCfgReadBytes (sizeof mFeatureControlValue, &mFeatureControlValue);
+  QemuFwCfgReadBytes (
+sizeof (PlatformInfoHob->FeatureControlValue),
+&(PlatformInfoHob->FeatureControlValue)
+);
 
   Status = PeiServicesNotifyPpi (&mMpServicesNotify);
   if (EFI_ERROR (Status)) {
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index ebce2ba1290e..148240342b4b 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -396,7 +396,7 @@ InitializePlatform (
   }
 
   IntelTdxInitialize ();
-  InstallFeatureControlCallback ();
+  InstallFeatureC

[edk2-devel] [PATCH 10/14] OvmfPkg/PlatformPei: remove mPlatformInfoHob

2022-12-02 Thread Gerd Hoffmann
Stop using the mPlatformInfoHob global variable.  Let
BuildPlatformInfoHob() allocate and return PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/PlatformPei/Platform.h |  4 +-
 OvmfPkg/PlatformPei/Platform.c | 71 ++
 2 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index 0c0558f0626c..86f603ff649c 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -13,8 +13,6 @@
 #include 
 #include 
 
-extern EFI_HOB_PLATFORM_INFO  mPlatformInfoHob;
-
 VOID
 AddressWidthInitialization (
   IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
@@ -98,7 +96,7 @@ IntelTdxInitialize (
 /**
  * @brief Builds PlatformInfo Hob
  */
-VOID
+EFI_HOB_PLATFORM_INFO *
 BuildPlatformInfoHob (
   VOID
   );
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index d8c4499804fb..ebce2ba1290e 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -41,8 +41,6 @@
 
 #include "Platform.h"
 
-EFI_HOB_PLATFORM_INFO  mPlatformInfoHob = { 0 };
-
 EFI_PEI_PPI_DESCRIPTOR  mPpiBootMode[] = {
   {
 EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
@@ -305,12 +303,18 @@ MaxCpuCountInitialization (
 /**
  * @brief Builds PlatformInfo Hob
  */
-VOID
+EFI_HOB_PLATFORM_INFO *
 BuildPlatformInfoHob (
   VOID
   )
 {
-  BuildGuidDataHob (&gUefiOvmfPkgPlatformInfoGuid, &mPlatformInfoHob, sizeof 
(EFI_HOB_PLATFORM_INFO));
+  EFI_HOB_PLATFORM_INFO  PlatformInfoHob;
+  EFI_HOB_GUID_TYPE  *GuidHob;
+
+  ZeroMem (&PlatformInfoHob, sizeof PlatformInfoHob);
+  BuildGuidDataHob (&gUefiOvmfPkgPlatformInfoGuid, &PlatformInfoHob, sizeof 
(EFI_HOB_PLATFORM_INFO));
+  GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid);
+  return (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob);
 }
 
 /**
@@ -329,69 +333,70 @@ InitializePlatform (
   IN CONST EFI_PEI_SERVICES **PeiServices
   )
 {
-  EFI_STATUS  Status;
+  EFI_HOB_PLATFORM_INFO  *PlatformInfoHob;
+  EFI_STATUS Status;
 
   DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n"));
+  PlatformInfoHob = BuildPlatformInfoHob ();
 
-  mPlatformInfoHob.SmmSmramRequire = FeaturePcdGet (PcdSmmSmramRequire);
-  mPlatformInfoHob.SevEsIsEnabled  = MemEncryptSevEsIsEnabled ();
-  mPlatformInfoHob.PcdPciMmio64Size= PcdGet64 (PcdPciMmio64Size);
-  mPlatformInfoHob.DefaultMaxCpuNumber = PcdGet32 
(PcdCpuMaxLogicalProcessorNumber);
+  PlatformInfoHob->SmmSmramRequire = FeaturePcdGet (PcdSmmSmramRequire);
+  PlatformInfoHob->SevEsIsEnabled  = MemEncryptSevEsIsEnabled ();
+  PlatformInfoHob->PcdPciMmio64Size= PcdGet64 (PcdPciMmio64Size);
+  PlatformInfoHob->DefaultMaxCpuNumber = PcdGet32 
(PcdCpuMaxLogicalProcessorNumber);
 
   PlatformDebugDumpCmos ();
 
   if (QemuFwCfgS3Enabled ()) {
 DEBUG ((DEBUG_INFO, "S3 support was detected on QEMU\n"));
-mPlatformInfoHob.S3Supported = TRUE;
+PlatformInfoHob->S3Supported = TRUE;
 Status   = PcdSetBoolS (PcdAcpiS3Enable, TRUE);
 ASSERT_EFI_ERROR (Status);
   }
 
-  S3Verification (&mPlatformInfoHob);
-  BootModeInitialization (&mPlatformInfoHob);
+  S3Verification (PlatformInfoHob);
+  BootModeInitialization (PlatformInfoHob);
 
   //
   // Query Host Bridge DID
   //
-  mPlatformInfoHob.HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
-  AddressWidthInitialization (&mPlatformInfoHob);
+  PlatformInfoHob->HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
+  AddressWidthInitialization (PlatformInfoHob);
 
-  MaxCpuCountInitialization (&mPlatformInfoHob);
+  MaxCpuCountInitialization (PlatformInfoHob);
 
-  if (mPlatformInfoHob.SmmSmramRequire) {
-Q35BoardVerification (&mPlatformInfoHob);
-Q35TsegMbytesInitialization (&mPlatformInfoHob);
-Q35SmramAtDefaultSmbaseInitialization (&mPlatformInfoHob);
+  if (PlatformInfoHob->SmmSmramRequire) {
+Q35BoardVerification (PlatformInfoHob);
+Q35TsegMbytesInitialization (PlatformInfoHob);
+Q35SmramAtDefaultSmbaseInitialization (PlatformInfoHob);
   }
 
-  PublishPeiMemory (&mPlatformInfoHob);
+  PublishPeiMemory (PlatformInfoHob);
 
-  PlatformQemuUc32BaseInitialization (&mPlatformInfoHob);
+  PlatformQemuUc32BaseInitialization (PlatformInfoHob);
 
-  InitializeRamRegions (&mPlatformInfoHob);
+  InitializeRamRegions (PlatformInfoHob);
 
-  if (mPlatformInfoHob.BootMode != BOOT_ON_S3_RESUME) {
-if (!mPlatformInfoHob.SmmSmramRequire) {
+  if (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) {
+if (!PlatformInfoHob->SmmSmramRequire) {
   ReserveEmuVariableNvStore ();
 }
 
-PeiFvInitialization (&mPlatformInfoHob);
-MemTypeInfoInitialization (&mPlatformInfoHob);
-MemMapInitialization (&mPlatformInfoHob);
-NoexecDxeInitialization (&mPlatformInfoHob);
+PeiFvInitialization (PlatformInfoHob);
+MemTypeInfoInitialization (PlatformInfoHob);
+MemMapInitialization (PlatformInfoHob);
+Noexec

[edk2-devel] [PATCH 07/14] OvmfPkg/PlatformPei: MemTypeInfo: stop using mPlatformInfoHob

2022-12-02 Thread Gerd Hoffmann
Stop using the mPlatformInfoHob global variable in MemTypeInfoInitialization()
function.  Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/PlatformPei/Platform.h| 2 +-
 OvmfPkg/PlatformPei/MemTypeInfo.c | 4 ++--
 OvmfPkg/PlatformPei/Platform.c| 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index d0c673c5a346..0c0558f0626c 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -67,7 +67,7 @@ PeiFvInitialization (
 
 VOID
 MemTypeInfoInitialization (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   );
 
 VOID
diff --git a/OvmfPkg/PlatformPei/MemTypeInfo.c 
b/OvmfPkg/PlatformPei/MemTypeInfo.c
index c8fcf1732687..eb37febb31ae 100644
--- a/OvmfPkg/PlatformPei/MemTypeInfo.c
+++ b/OvmfPkg/PlatformPei/MemTypeInfo.c
@@ -203,12 +203,12 @@ STATIC CONST EFI_PEI_NOTIFY_DESCRIPTOR  
mReadOnlyVariable2Notify = {
 
 VOID
 MemTypeInfoInitialization (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   EFI_STATUS  Status;
 
-  if (!mPlatformInfoHob.SmmSmramRequire) {
+  if (!PlatformInfoHob->SmmSmramRequire) {
 //
 // EFI_PEI_READ_ONLY_VARIABLE2_PPI will never be available; install
 // the default memory type information HOB right away.
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 4cd77fd5f84f..85b47e7ed8df 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -373,7 +373,7 @@ InitializePlatform (
 }
 
 PeiFvInitialization (&mPlatformInfoHob);
-MemTypeInfoInitialization ();
+MemTypeInfoInitialization (&mPlatformInfoHob);
 MemMapInitialization (&mPlatformInfoHob);
 NoexecDxeInitialization ();
   }
-- 
2.38.1



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




[edk2-devel] [PATCH 09/14] OvmfPkg/PlatformPei: Verification: stop using mPlatformInfoHob

2022-12-02 Thread Gerd Hoffmann
Stop using the mPlatformInfoHob global variable in S3Verification() and
Q35BoardVerification() functions.  Pass a pointer to the PlatformInfoHob
instead.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/PlatformPei/Platform.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 7f3a26092626..d8c4499804fb 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -231,13 +231,14 @@ ReserveEmuVariableNvStore (
   ASSERT_RETURN_ERROR (PcdStatus);
 }
 
+STATIC
 VOID
 S3Verification (
-  VOID
+  IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
  #if defined (MDE_CPU_X64)
-  if (mPlatformInfoHob.SmmSmramRequire && mPlatformInfoHob.S3Supported) {
+  if (PlatformInfoHob->SmmSmramRequire && PlatformInfoHob->S3Supported) {
 DEBUG ((
   DEBUG_ERROR,
   "%a: S3Resume2Pei doesn't support X64 PEI + SMM yet.\n",
@@ -260,12 +261,13 @@ S3Verification (
  #endif
 }
 
+STATIC
 VOID
 Q35BoardVerification (
-  VOID
+  IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
-  if (mPlatformInfoHob.HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {
+  if (PlatformInfoHob->HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {
 return;
   }
 
@@ -274,7 +276,7 @@ Q35BoardVerification (
 "%a: no TSEG (SMRAM) on host bridge DID=0x%04x; "
 "only DID=0x%04x (Q35) is supported\n",
 __FUNCTION__,
-mPlatformInfoHob.HostBridgeDevId,
+PlatformInfoHob->HostBridgeDevId,
 INTEL_Q35_MCH_DEVICE_ID
 ));
   ASSERT (FALSE);
@@ -345,7 +347,7 @@ InitializePlatform (
 ASSERT_EFI_ERROR (Status);
   }
 
-  S3Verification ();
+  S3Verification (&mPlatformInfoHob);
   BootModeInitialization (&mPlatformInfoHob);
 
   //
@@ -357,7 +359,7 @@ InitializePlatform (
   MaxCpuCountInitialization (&mPlatformInfoHob);
 
   if (mPlatformInfoHob.SmmSmramRequire) {
-Q35BoardVerification ();
+Q35BoardVerification (&mPlatformInfoHob);
 Q35TsegMbytesInitialization (&mPlatformInfoHob);
 Q35SmramAtDefaultSmbaseInitialization (&mPlatformInfoHob);
   }
-- 
2.38.1



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




[edk2-devel] [PATCH 08/14] OvmfPkg/PlatformPei: NoExec: stop using mPlatformInfoHob

2022-12-02 Thread Gerd Hoffmann
Stop using the mPlatformInfoHob global variable in NoexecDxeInitialization()
function.  Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/PlatformPei/Platform.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 85b47e7ed8df..7f3a26092626 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -75,16 +75,17 @@ MemMapInitialization (
   ASSERT_RETURN_ERROR (PcdStatus);
 }
 
+STATIC
 VOID
 NoexecDxeInitialization (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   RETURN_STATUS  Status;
 
-  Status = PlatformNoexecDxeInitialization (&mPlatformInfoHob);
+  Status = PlatformNoexecDxeInitialization (PlatformInfoHob);
   if (!RETURN_ERROR (Status)) {
-Status = PcdSetBoolS (PcdSetNxForStack, mPlatformInfoHob.PcdSetNxForStack);
+Status = PcdSetBoolS (PcdSetNxForStack, PlatformInfoHob->PcdSetNxForStack);
 ASSERT_RETURN_ERROR (Status);
   }
 }
@@ -375,7 +376,7 @@ InitializePlatform (
 PeiFvInitialization (&mPlatformInfoHob);
 MemTypeInfoInitialization (&mPlatformInfoHob);
 MemMapInitialization (&mPlatformInfoHob);
-NoexecDxeInitialization ();
+NoexecDxeInitialization (&mPlatformInfoHob);
   }
 
   InstallClearCacheCallback ();
-- 
2.38.1



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




[edk2-devel] [PATCH 05/14] OvmfPkg/PlatformPei Q35 SMM helpers: stop using mPlatformInfoHob

2022-12-02 Thread Gerd Hoffmann
Stop using the mPlatformInfoHob global variable in
Q35TsegMbytesInitialization() and
Q35SmramAtDefaultSmbaseInitialization() ) functions.
Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/PlatformPei/Platform.h  |  4 ++--
 OvmfPkg/PlatformPei/MemDetect.c | 20 ++--
 OvmfPkg/PlatformPei/Platform.c  |  4 ++--
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index b13f45ecdb69..7baa5e1d289f 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -22,12 +22,12 @@ AddressWidthInitialization (
 
 VOID
 Q35TsegMbytesInitialization (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   );
 
 VOID
 Q35SmramAtDefaultSmbaseInitialization (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   );
 
 EFI_STATUS
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index 2e47b1322990..b9207107b4d9 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -41,13 +41,13 @@ Module Name:
 
 VOID
 Q35TsegMbytesInitialization (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   UINT16 ExtendedTsegMbytes;
   RETURN_STATUS  PcdStatus;
 
-  ASSERT (mPlatformInfoHob.HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID);
+  ASSERT (PlatformInfoHob->HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID);
 
   //
   // Check if QEMU offers an extended TSEG.
@@ -68,7 +68,7 @@ Q35TsegMbytesInitialization (
   PciWrite16 (DRAMC_REGISTER_Q35 (MCH_EXT_TSEG_MB), MCH_EXT_TSEG_MB_QUERY);
   ExtendedTsegMbytes = PciRead16 (DRAMC_REGISTER_Q35 (MCH_EXT_TSEG_MB));
   if (ExtendedTsegMbytes == MCH_EXT_TSEG_MB_QUERY) {
-mPlatformInfoHob.Q35TsegMbytes = PcdGet16 (PcdQ35TsegMbytes);
+PlatformInfoHob->Q35TsegMbytes = PcdGet16 (PcdQ35TsegMbytes);
 return;
   }
 
@@ -80,19 +80,19 @@ Q35TsegMbytesInitialization (
 ));
   PcdStatus = PcdSet16S (PcdQ35TsegMbytes, ExtendedTsegMbytes);
   ASSERT_RETURN_ERROR (PcdStatus);
-  mPlatformInfoHob.Q35TsegMbytes = ExtendedTsegMbytes;
+  PlatformInfoHob->Q35TsegMbytes = ExtendedTsegMbytes;
 }
 
 VOID
 Q35SmramAtDefaultSmbaseInitialization (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   RETURN_STATUS  PcdStatus;
 
-  ASSERT (mPlatformInfoHob.HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID);
+  ASSERT (PlatformInfoHob->HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID);
 
-  mPlatformInfoHob.Q35SmramAtDefaultSmbase = FALSE;
+  PlatformInfoHob->Q35SmramAtDefaultSmbase = FALSE;
   if (FeaturePcdGet (PcdCsmEnable)) {
 DEBUG ((
   DEBUG_INFO,
@@ -106,19 +106,19 @@ Q35SmramAtDefaultSmbaseInitialization (
 CtlReg = DRAMC_REGISTER_Q35 (MCH_DEFAULT_SMBASE_CTL);
 PciWrite8 (CtlReg, MCH_DEFAULT_SMBASE_QUERY);
 CtlRegVal= PciRead8 (CtlReg);
-mPlatformInfoHob.Q35SmramAtDefaultSmbase = (BOOLEAN)(CtlRegVal ==
+PlatformInfoHob->Q35SmramAtDefaultSmbase = (BOOLEAN)(CtlRegVal ==
  
MCH_DEFAULT_SMBASE_IN_RAM);
 DEBUG ((
   DEBUG_INFO,
   "%a: SMRAM at default SMBASE %a\n",
   __FUNCTION__,
-  mPlatformInfoHob.Q35SmramAtDefaultSmbase ? "found" : "not found"
+  PlatformInfoHob->Q35SmramAtDefaultSmbase ? "found" : "not found"
   ));
   }
 
   PcdStatus = PcdSetBoolS (
 PcdQ35SmramAtDefaultSmbase,
-mPlatformInfoHob.Q35SmramAtDefaultSmbase
+PlatformInfoHob->Q35SmramAtDefaultSmbase
 );
   ASSERT_RETURN_ERROR (PcdStatus);
 }
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 9646a1fa63b0..8b055fb451d7 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -357,8 +357,8 @@ InitializePlatform (
 
   if (mPlatformInfoHob.SmmSmramRequire) {
 Q35BoardVerification ();
-Q35TsegMbytesInitialization ();
-Q35SmramAtDefaultSmbaseInitialization ();
+Q35TsegMbytesInitialization (&mPlatformInfoHob);
+Q35SmramAtDefaultSmbaseInitialization (&mPlatformInfoHob);
   }
 
   PublishPeiMemory ();
-- 
2.38.1



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




[edk2-devel] [PATCH 06/14] OvmfPkg/PlatformPei: PeiMemory: stop using mPlatformInfoHob

2022-12-02 Thread Gerd Hoffmann
Stop using the mPlatformInfoHob global variable in PublishPeiMemory()
and GetPeiMemoryCap() functions.  Pass a pointer to the PlatformInfoHob
instead.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/PlatformPei/Platform.h  |  2 +-
 OvmfPkg/PlatformPei/MemDetect.c | 36 -
 OvmfPkg/PlatformPei/Platform.c  |  2 +-
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index 7baa5e1d289f..d0c673c5a346 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -32,7 +32,7 @@ Q35SmramAtDefaultSmbaseInitialization (
 
 EFI_STATUS
 PublishPeiMemory (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   );
 
 VOID
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index b9207107b4d9..3d8375320dcb 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -188,7 +188,7 @@ AddressWidthInitialization (
 STATIC
 UINT32
 GetPeiMemoryCap (
-  VOID
+  IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   BOOLEAN  Page1GSupport;
@@ -225,15 +225,15 @@ GetPeiMemoryCap (
 }
   }
 
-  if (mPlatformInfoHob.PhysMemAddressWidth <= 39) {
+  if (PlatformInfoHob->PhysMemAddressWidth <= 39) {
 Pml4Entries = 1;
-PdpEntries  = 1 << (mPlatformInfoHob.PhysMemAddressWidth - 30);
+PdpEntries  = 1 << (PlatformInfoHob->PhysMemAddressWidth - 30);
 ASSERT (PdpEntries <= 0x200);
   } else {
-if (mPlatformInfoHob.PhysMemAddressWidth > 48) {
+if (PlatformInfoHob->PhysMemAddressWidth > 48) {
   Pml4Entries = 0x200;
 } else {
-  Pml4Entries = 1 << (mPlatformInfoHob.PhysMemAddressWidth - 39);
+  Pml4Entries = 1 << (PlatformInfoHob->PhysMemAddressWidth - 39);
 }
 
 ASSERT (Pml4Entries <= 0x200);
@@ -260,7 +260,7 @@ GetPeiMemoryCap (
 **/
 EFI_STATUS
 PublishPeiMemory (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   EFI_STATUSStatus;
@@ -271,12 +271,12 @@ PublishPeiMemory (
   UINT32S3AcpiReservedMemoryBase;
   UINT32S3AcpiReservedMemorySize;
 
-  LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (&mPlatformInfoHob);
-  if (mPlatformInfoHob.SmmSmramRequire) {
+  LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob);
+  if (PlatformInfoHob->SmmSmramRequire) {
 //
 // TSEG is chipped from the end of low RAM
 //
-LowerMemorySize -= mPlatformInfoHob.Q35TsegMbytes * SIZE_1MB;
+LowerMemorySize -= PlatformInfoHob->Q35TsegMbytes * SIZE_1MB;
   }
 
   S3AcpiReservedMemoryBase = 0;
@@ -287,27 +287,27 @@ PublishPeiMemory (
   // downwards. Its size is primarily dictated by CpuMpPei. The formula below
   // is an approximation.
   //
-  if (mPlatformInfoHob.S3Supported) {
+  if (PlatformInfoHob->S3Supported) {
 S3AcpiReservedMemorySize = SIZE_512KB +
-   
mPlatformInfoHob.PcdCpuMaxLogicalProcessorNumber *
+   
PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber *
PcdGet32 (PcdCpuApStackSize);
 S3AcpiReservedMemoryBase = LowerMemorySize - S3AcpiReservedMemorySize;
 LowerMemorySize  = S3AcpiReservedMemoryBase;
   }
 
-  mPlatformInfoHob.S3AcpiReservedMemoryBase = S3AcpiReservedMemoryBase;
-  mPlatformInfoHob.S3AcpiReservedMemorySize = S3AcpiReservedMemorySize;
+  PlatformInfoHob->S3AcpiReservedMemoryBase = S3AcpiReservedMemoryBase;
+  PlatformInfoHob->S3AcpiReservedMemorySize = S3AcpiReservedMemorySize;
 
-  if (mPlatformInfoHob.BootMode == BOOT_ON_S3_RESUME) {
+  if (PlatformInfoHob->BootMode == BOOT_ON_S3_RESUME) {
 MemoryBase = S3AcpiReservedMemoryBase;
 MemorySize = S3AcpiReservedMemorySize;
   } else {
-PeiMemoryCap = GetPeiMemoryCap ();
+PeiMemoryCap = GetPeiMemoryCap (PlatformInfoHob);
 DEBUG ((
   DEBUG_INFO,
   "%a: PhysMemAddressWidth=%d PeiMemoryCap=%u KB\n",
   __FUNCTION__,
-  mPlatformInfoHob.PhysMemAddressWidth,
+  PlatformInfoHob->PhysMemAddressWidth,
   PeiMemoryCap >> 10
   ));
 
@@ -321,7 +321,7 @@ PublishPeiMemory (
 // allocation HOB, and other allocations served from the permanent PEI RAM
 // shouldn't overlap with that HOB.
 //
-MemoryBase = mPlatformInfoHob.S3Supported && 
mPlatformInfoHob.SmmSmramRequire ?
+MemoryBase = PlatformInfoHob->S3Supported && 
PlatformInfoHob->SmmSmramRequire ?
  PcdGet32 (PcdOvmfDecompressionScratchEnd) :
  PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 
(PcdOvmfDxeMemFvSize);
 MemorySize = LowerMemorySize - MemoryBase;
@@ -336,7 +336,7 @@ PublishPeiMemory (
   // normal boot permanent PEI RAM. Regarding the S3 boot path, the S3
   // permanent PEI RAM is located even higher.
   //
-  if (mPlatformInfoHob.SmmSmramRequire && 
mPlatformInfoHob.Q35SmramAtDefaultSmbase) {
+  if (PlatformInfoHob->SmmSmramRequire && 
PlatformInfoHob->Q35SmramAtDefaultSmbase) {
 ASSERT (SMM

[edk2-devel] [PATCH 02/14] tools_def: add -fno-omit-frame-pointer to GCC48_{IA32,X64}_CC_FLAGS

2022-12-02 Thread Gerd Hoffmann
Fixes problems due to code assuming it runs with frame pointers and thus
updates rbp / ebp registers when switching stacks.

Signed-off-by: Gerd Hoffmann 
---
 BaseTools/Conf/tools_def.template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 73f95b2a3a9f..f1fd6a003062 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1888,8 +1888,8 @@ DEFINE GCC_DEPS_FLAGS  = -MMD -MF $@.deps
 
 DEFINE GCC48_ALL_CC_FLAGS= DEF(GCC_ALL_CC_FLAGS) 
-ffunction-sections -fdata-sections -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
 DEFINE GCC48_IA32_X64_DLINK_COMMON   = -nostdlib -Wl,-n,-q,--gc-sections -z 
common-page-size=0x20
-DEFINE GCC48_IA32_CC_FLAGS   = DEF(GCC48_ALL_CC_FLAGS) -m32 
-march=i586 -malign-double -fno-stack-protector -D EFI32 
-fno-asynchronous-unwind-tables -Wno-address
-DEFINE GCC48_X64_CC_FLAGS= DEF(GCC48_ALL_CC_FLAGS) -m64 
-fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" 
-maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie 
-fno-asynchronous-unwind-tables -Wno-address
+DEFINE GCC48_IA32_CC_FLAGS   = DEF(GCC48_ALL_CC_FLAGS) -m32 
-march=i586 -malign-double -fno-stack-protector -D EFI32 
-fno-asynchronous-unwind-tables -Wno-address -fno-omit-frame-pointer
+DEFINE GCC48_X64_CC_FLAGS= DEF(GCC48_ALL_CC_FLAGS) -m64 
-fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" 
-maccumulate-outgoing-args -mno-red-zone -Wno-address -mcmodel=small -fpie 
-fno-asynchronous-unwind-tables -Wno-address  -fno-omit-frame-pointer
 DEFINE GCC48_IA32_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_DLINK_COMMON) 
-Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
 DEFINE GCC48_IA32_X64_DLINK_FLAGS= DEF(GCC48_IA32_X64_DLINK_COMMON) 
-Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) 
-Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
 DEFINE GCC48_IA32_DLINK2_FLAGS   = -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 
DEF(GCC_DLINK2_FLAGS_COMMON)
-- 
2.38.1



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




[edk2-devel] [PATCH 04/14] OvmfPkg/PlatformPei: PeiFv: stop using mPlatformInfoHob

2022-12-02 Thread Gerd Hoffmann
Stop using the mPlatformInfoHob global variable in PeiFvInitialization()
function.  Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/PlatformPei/Platform.h | 2 +-
 OvmfPkg/PlatformPei/Fv.c   | 6 +++---
 OvmfPkg/PlatformPei/Platform.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index f245025fb46f..b13f45ecdb69 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -62,7 +62,7 @@ MaxCpuCountInitialization (
 
 EFI_STATUS
 PeiFvInitialization (
-  VOID
+  IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   );
 
 VOID
diff --git a/OvmfPkg/PlatformPei/Fv.c b/OvmfPkg/PlatformPei/Fv.c
index e40c5922206b..fcf14c88faa7 100644
--- a/OvmfPkg/PlatformPei/Fv.c
+++ b/OvmfPkg/PlatformPei/Fv.c
@@ -22,7 +22,7 @@
 **/
 EFI_STATUS
 PeiFvInitialization (
-  VOID
+  IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   BOOLEAN  SecureS3Needed;
@@ -37,7 +37,7 @@ PeiFvInitialization (
   BuildMemoryAllocationHob (
 PcdGet32 (PcdOvmfPeiMemFvBase),
 PcdGet32 (PcdOvmfPeiMemFvSize),
-mPlatformInfoHob.S3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
+PlatformInfoHob->S3Supported ? EfiACPIMemoryNVS : EfiBootServicesData
 );
 
   //
@@ -45,7 +45,7 @@ PeiFvInitialization (
   //
   BuildFvHob (PcdGet32 (PcdOvmfDxeMemFvBase), PcdGet32 (PcdOvmfDxeMemFvSize));
 
-  SecureS3Needed = mPlatformInfoHob.S3Supported && 
mPlatformInfoHob.SmmSmramRequire;
+  SecureS3Needed = PlatformInfoHob->S3Supported && 
PlatformInfoHob->SmmSmramRequire;
 
   //
   // Create a memory allocation HOB for the DXE FV.
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index f2c1e2b213cb..9646a1fa63b0 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -372,7 +372,7 @@ InitializePlatform (
   ReserveEmuVariableNvStore ();
 }
 
-PeiFvInitialization ();
+PeiFvInitialization (&mPlatformInfoHob);
 MemTypeInfoInitialization ();
 MemMapInitialization (&mPlatformInfoHob);
 NoexecDxeInitialization ();
-- 
2.38.1



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




[edk2-devel] [PATCH 03/14] OvmfPkg/PlatformPei: AmdSev: stop using mPlatformInfoHob

2022-12-02 Thread Gerd Hoffmann
Stop using the mPlatformInfoHob global variable in AmdSevInitialize()
and AmdSevEsInitialize() functions.  Pass a pointer to the
PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/PlatformPei/Platform.h |  2 +-
 OvmfPkg/PlatformPei/AmdSev.c   | 14 +++---
 OvmfPkg/PlatformPei/Platform.c |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index 29b51b2debd8..f245025fb46f 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -82,7 +82,7 @@ InstallClearCacheCallback (
 
 VOID
 AmdSevInitialize (
-  VOID
+  IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   );
 
 /**
diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c
index e1b9fd9b7f68..c23fae7fcae0 100644
--- a/OvmfPkg/PlatformPei/AmdSev.c
+++ b/OvmfPkg/PlatformPei/AmdSev.c
@@ -201,7 +201,7 @@ GhcbRegister (
 STATIC
 VOID
 AmdSevEsInitialize (
-  VOID
+  IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   UINT8*GhcbBase;
@@ -228,7 +228,7 @@ AmdSevEsInitialize (
   //   Since the pages must survive across the UEFI to OS transition
   //   make them reserved.
   //
-  GhcbPageCount = mPlatformInfoHob.PcdCpuMaxLogicalProcessorNumber * 2;
+  GhcbPageCount = PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber * 2;
   GhcbBase  = AllocateReservedPages (GhcbPageCount);
   ASSERT (GhcbBase != NULL);
 
@@ -266,7 +266,7 @@ AmdSevEsInitialize (
   // Allocate #VC recursion backup pages. The number of backup pages needed is
   // one less than the maximum VC count.
   //
-  GhcbBackupPageCount = mPlatformInfoHob.PcdCpuMaxLogicalProcessorNumber * 
(VMGEXIT_MAXIMUM_VC_COUNT - 1);
+  GhcbBackupPageCount = PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber * 
(VMGEXIT_MAXIMUM_VC_COUNT - 1);
   GhcbBackupBase  = AllocatePages (GhcbBackupPageCount);
   ASSERT (GhcbBackupBase != NULL);
 
@@ -320,7 +320,7 @@ AmdSevEsInitialize (
   **/
 VOID
 AmdSevInitialize (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   UINT64 EncryptionMask;
@@ -367,7 +367,7 @@ AmdSevInitialize (
   // until after re-encryption, in order to prevent an information leak to the
   // hypervisor.
   //
-  if (mPlatformInfoHob.SmmSmramRequire && (mPlatformInfoHob.BootMode != 
BOOT_ON_S3_RESUME)) {
+  if (PlatformInfoHob->SmmSmramRequire && (PlatformInfoHob->BootMode != 
BOOT_ON_S3_RESUME)) {
 RETURN_STATUS  LocateMapStatus;
 UINTN  MapPagesBase;
 UINTN  MapPagesCount;
@@ -378,7 +378,7 @@ AmdSevInitialize (
 );
 ASSERT_RETURN_ERROR (LocateMapStatus);
 
-if (mPlatformInfoHob.Q35SmramAtDefaultSmbase) {
+if (PlatformInfoHob->Q35SmramAtDefaultSmbase) {
   //
   // The initial SMRAM Save State Map has been covered as part of a larger
   // reserved memory allocation in InitializeRamRegions().
@@ -400,7 +400,7 @@ AmdSevInitialize (
   //
   // Check and perform SEV-ES initialization if required.
   //
-  AmdSevEsInitialize ();
+  AmdSevEsInitialize (PlatformInfoHob);
 
   //
   // Set the Confidential computing attr PCD to communicate which SEV
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index b1f8140d6041..f2c1e2b213cb 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -379,7 +379,7 @@ InitializePlatform (
   }
 
   InstallClearCacheCallback ();
-  AmdSevInitialize ();
+  AmdSevInitialize (&mPlatformInfoHob);
   if (mPlatformInfoHob.HostBridgeDevId == 0x) {
 MiscInitializationForMicrovm (&mPlatformInfoHob);
   } else {
-- 
2.38.1



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




[edk2-devel] [PATCH 01/14] tools_def: remove GCC_IA32_CC_FLAGS/GCC_X64_CC_FLAGS

2022-12-02 Thread Gerd Hoffmann
They are not used anywhere.  Remove them.

Signed-off-by: Gerd Hoffmann 
---
 BaseTools/Conf/tools_def.template | 2 --
 1 file changed, 2 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index c4e4c7ded0af..73f95b2a3a9f 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1850,8 +1850,6 @@ NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = 
--add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_N
 *_*_*_DTC_PATH = DEF(DTC_BIN)
 
 DEFINE GCC_ALL_CC_FLAGS= -g -Os -fshort-wchar -fno-builtin 
-fno-strict-aliasing -Wall -Werror -Wno-array-bounds -include AutoGen.h 
-fno-common
-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) -mabi=lp64d 
-fno-asynchronous-unwind-tables -fno-plt -Wno-address -fno-short-enums 
-fsigned-char -ffunction-sections -fdata-sections
 DEFINE GCC_ARM_CC_XIPFLAGS = -mno-unaligned-access
-- 
2.38.1



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




[edk2-devel] [PATCH 00/14] OvmfPkg: avoid global variables in PEI

2022-12-02 Thread Gerd Hoffmann
Writing to global variables changes the PEI firmware volume which in
turn screws up firmware volume measurements.  Fix OvmfPkg to avoid that,
for the most part by using the PlatformInfoHob instead.

Gerd Hoffmann (14):
  tools_def: remove GCC_IA32_CC_FLAGS/GCC_X64_CC_FLAGS
  tools_def: add -fno-omit-frame-pointer to GCC48_{IA32,X64}_CC_FLAGS
  OvmfPkg/PlatformPei: AmdSev: stop using mPlatformInfoHob
  OvmfPkg/PlatformPei: PeiFv: stop using mPlatformInfoHob
  OvmfPkg/PlatformPei Q35 SMM helpers: stop using mPlatformInfoHob
  OvmfPkg/PlatformPei: PeiMemory: stop using mPlatformInfoHob
  OvmfPkg/PlatformPei: MemTypeInfo: stop using mPlatformInfoHob
  OvmfPkg/PlatformPei: NoExec: stop using mPlatformInfoHob
  OvmfPkg/PlatformPei: Verification: stop using mPlatformInfoHob
  OvmfPkg/PlatformPei: remove mPlatformInfoHob
  OvmfPkg/PlatformPei: remove mFeatureControlValue
  OvmfPkg/DebugLibIoPort: use Rom version for PEI
  OvmfPkg/QemuFwCfgLib: rewrite fw_cfg probe
  OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported +
mQemuFwCfgDmaSupported

 OvmfPkg/AmdSev/AmdSevX64.dsc  |   4 +-
 OvmfPkg/Bhyve/BhyveX64.dsc|   4 +-
 OvmfPkg/Microvm/MicrovmX64.dsc|   4 +-
 OvmfPkg/OvmfPkgIa32.dsc   |   4 +-
 OvmfPkg/OvmfPkgIa32X64.dsc|   4 +-
 OvmfPkg/OvmfPkgX64.dsc|   4 +-
 .../PlatformRomDebugLibIoPort.inf |   2 +-
 .../Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf  |   5 +-
 OvmfPkg/Include/Library/PlatformInitLib.h |   6 +
 OvmfPkg/PlatformPei/Platform.h|  18 +--
 OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c   | 143 ++
 OvmfPkg/PlatformPei/AmdSev.c  |  14 +-
 OvmfPkg/PlatformPei/FeatureControl.c  |  44 --
 OvmfPkg/PlatformPei/Fv.c  |   6 +-
 OvmfPkg/PlatformPei/MemDetect.c   |  56 +++
 OvmfPkg/PlatformPei/MemTypeInfo.c |   4 +-
 OvmfPkg/PlatformPei/Platform.c|  92 ++-
 BaseTools/Conf/tools_def.template |   6 +-
 18 files changed, 232 insertions(+), 188 deletions(-)

-- 
2.38.1



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




[edk2-devel] [PATCH 2/3] OvmfPkg: move dsc include snippet for Network support to inc subdir

2022-12-02 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/{ => inc}/NetworkComponents.dsc.inc | 0
 OvmfPkg/CloudHv/CloudHvX64.dsc  | 2 +-
 OvmfPkg/Microvm/MicrovmX64.dsc  | 2 +-
 OvmfPkg/OvmfPkgIa32.dsc | 2 +-
 OvmfPkg/OvmfPkgIa32X64.dsc  | 2 +-
 OvmfPkg/OvmfPkgX64.dsc  | 2 +-
 6 files changed, 5 insertions(+), 5 deletions(-)
 rename OvmfPkg/{ => inc}/NetworkComponents.dsc.inc (100%)

diff --git a/OvmfPkg/NetworkComponents.dsc.inc 
b/OvmfPkg/inc/NetworkComponents.dsc.inc
similarity index 100%
rename from OvmfPkg/NetworkComponents.dsc.inc
rename to OvmfPkg/inc/NetworkComponents.dsc.inc
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index 79a73a63099f..9bb7b8043544 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -827,7 +827,7 @@ [Components]
   # Network Support
   #
 !include NetworkPkg/NetworkComponents.dsc.inc
-!include OvmfPkg/NetworkComponents.dsc.inc
+!include OvmfPkg/inc/NetworkComponents.dsc.inc
 
   OvmfPkg/VirtioNetDxe/VirtioNet.inf
 
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 49c77ecf32e3..abcefb8824f0 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -817,7 +817,7 @@ [Components]
   # Network Support
   #
 !include NetworkPkg/NetworkComponents.dsc.inc
-!include OvmfPkg/NetworkComponents.dsc.inc
+!include OvmfPkg/inc/NetworkComponents.dsc.inc
 
   OvmfPkg/VirtioNetDxe/VirtioNet.inf
 
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index ba41816de4c9..f27e9634ec62 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -879,7 +879,7 @@ [Components]
   # Network Support
   #
 !include NetworkPkg/NetworkComponents.dsc.inc
-!include OvmfPkg/NetworkComponents.dsc.inc
+!include OvmfPkg/inc/NetworkComponents.dsc.inc
 
   OvmfPkg/VirtioNetDxe/VirtioNet.inf
 
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index c26d6a353849..631014cd60a3 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -893,7 +893,7 @@ [Components.X64]
   # Network Support
   #
 !include NetworkPkg/NetworkComponents.dsc.inc
-!include OvmfPkg/NetworkComponents.dsc.inc
+!include OvmfPkg/inc/NetworkComponents.dsc.inc
 
   OvmfPkg/VirtioNetDxe/VirtioNet.inf
 
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index dc213ca3c1f9..12de436a7910 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -961,7 +961,7 @@ [Components]
   # Network Support
   #
 !include NetworkPkg/NetworkComponents.dsc.inc
-!include OvmfPkg/NetworkComponents.dsc.inc
+!include OvmfPkg/inc/NetworkComponents.dsc.inc
 
   OvmfPkg/VirtioNetDxe/VirtioNet.inf
 
-- 
2.38.1



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




[edk2-devel] [PATCH 0/3] OvmfPkg: move include files to inc subdir

2022-12-02 Thread Gerd Hoffmann
We have a number of include files for *.dsc and *.fdf in OvmfPkg/, lets
unclutter the directory a bit by moving them all to a subdirectory.

Gerd Hoffmann (3):
  OvmfPkg: move dsc and fdf include snippets for TPM support to inc
subdir
  OvmfPkg: move dsc include snippet for Network support to inc subdir
  OvmfPkg: move fdf include snippets to inc subdirectory

 OvmfPkg/{ => inc}/NetworkComponents.dsc.inc  |  0
 OvmfPkg/{ => inc}/OvmfTpmComponentsDxe.dsc.inc   |  0
 OvmfPkg/{ => inc}/OvmfTpmComponentsPei.dsc.inc   |  0
 OvmfPkg/{ => inc}/OvmfTpmDefines.dsc.inc |  0
 OvmfPkg/{ => inc}/OvmfTpmLibs.dsc.inc|  0
 OvmfPkg/{ => inc}/OvmfTpmPcds.dsc.inc|  0
 OvmfPkg/{ => inc}/OvmfTpmPcdsHii.dsc.inc |  0
 OvmfPkg/{ => inc}/OvmfTpmSecurityStub.dsc.inc|  0
 OvmfPkg/AmdSev/AmdSevX64.dsc | 14 +++---
 OvmfPkg/CloudHv/CloudHvX64.dsc   | 16 
 OvmfPkg/Microvm/MicrovmX64.dsc   |  4 ++--
 OvmfPkg/OvmfPkgIa32.dsc  | 16 
 OvmfPkg/OvmfPkgIa32X64.dsc   | 16 
 OvmfPkg/OvmfPkgX64.dsc   | 16 
 OvmfPkg/AmdSev/AmdSevX64.fdf | 10 +-
 OvmfPkg/Bhyve/BhyveX64.fdf   |  6 +++---
 OvmfPkg/CloudHv/CloudHvX64.fdf   |  6 +++---
 OvmfPkg/IntelTdx/IntelTdxX64.fdf |  8 
 OvmfPkg/Microvm/MicrovmX64.fdf   |  6 +++---
 OvmfPkg/OvmfPkgIa32.fdf  | 12 ++--
 OvmfPkg/OvmfPkgIa32X64.fdf   | 12 ++--
 OvmfPkg/OvmfPkgX64.fdf   | 12 ++--
 OvmfPkg/OvmfXen.fdf  |  8 
 OvmfPkg/Include/WorkArea.h   |  2 +-
 OvmfPkg/Sec/AmdSev.h |  2 +-
 OvmfPkg/Sec/AmdSev.c |  2 +-
 .../{ => inc}/FvmainCompactScratchEnd.fdf.inc|  0
 OvmfPkg/{ => inc}/OvmfPkgDefines.fdf.inc |  0
 OvmfPkg/{ => inc}/OvmfTpmDxe.fdf.inc |  0
 OvmfPkg/{ => inc}/OvmfTpmPei.fdf.inc |  0
 OvmfPkg/{ => inc}/VarStore.fdf.inc   |  0
 OvmfPkg/{ => inc}/XenElfHeader.fdf.inc   |  0
 32 files changed, 84 insertions(+), 84 deletions(-)
 rename OvmfPkg/{ => inc}/NetworkComponents.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmComponentsDxe.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmComponentsPei.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmDefines.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmLibs.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmPcds.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmPcdsHii.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmSecurityStub.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/FvmainCompactScratchEnd.fdf.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfPkgDefines.fdf.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmDxe.fdf.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmPei.fdf.inc (100%)
 rename OvmfPkg/{ => inc}/VarStore.fdf.inc (100%)
 rename OvmfPkg/{ => inc}/XenElfHeader.fdf.inc (100%)

-- 
2.38.1



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




[edk2-devel] [PATCH 3/3] OvmfPkg: move fdf include snippets to inc subdirectory

2022-12-02 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/AmdSev/AmdSevX64.fdf  | 6 +++---
 OvmfPkg/Bhyve/BhyveX64.fdf| 6 +++---
 OvmfPkg/CloudHv/CloudHvX64.fdf| 2 +-
 OvmfPkg/IntelTdx/IntelTdxX64.fdf  | 8 
 OvmfPkg/Microvm/MicrovmX64.fdf| 6 +++---
 OvmfPkg/OvmfPkgIa32.fdf   | 8 
 OvmfPkg/OvmfPkgIa32X64.fdf| 8 
 OvmfPkg/OvmfPkgX64.fdf| 8 
 OvmfPkg/OvmfXen.fdf   | 8 
 OvmfPkg/Include/WorkArea.h| 2 +-
 OvmfPkg/Sec/AmdSev.h  | 2 +-
 OvmfPkg/Sec/AmdSev.c  | 2 +-
 OvmfPkg/{ => inc}/FvmainCompactScratchEnd.fdf.inc | 0
 OvmfPkg/{ => inc}/OvmfPkgDefines.fdf.inc  | 0
 OvmfPkg/{ => inc}/VarStore.fdf.inc| 0
 OvmfPkg/{ => inc}/XenElfHeader.fdf.inc| 0
 16 files changed, 33 insertions(+), 33 deletions(-)
 rename OvmfPkg/{ => inc}/FvmainCompactScratchEnd.fdf.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfPkgDefines.fdf.inc (100%)
 rename OvmfPkg/{ => inc}/VarStore.fdf.inc (100%)
 rename OvmfPkg/{ => inc}/XenElfHeader.fdf.inc (100%)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf
index bd23888e819f..dc110bd5bc7b 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.fdf
+++ b/OvmfPkg/AmdSev/AmdSevX64.fdf
@@ -11,7 +11,7 @@
 

 
 [Defines]
-!include OvmfPkg/OvmfPkgDefines.fdf.inc
+!include OvmfPkg/inc/OvmfPkgDefines.fdf.inc
 
 #
 # Build the variable store and the firmware code as one unified flash device
@@ -24,7 +24,7 @@ [FD.OVMF]
 BlockSize = $(BLOCK_SIZE)
 NumBlocks = $(FW_BLOCKS)
 
-!include OvmfPkg/VarStore.fdf.inc
+!include OvmfPkg/inc/VarStore.fdf.inc
 
 $(VARS_SIZE)|$(FVMAIN_SIZE)
 FV = FVMAIN_COMPACT
@@ -351,7 +351,7 @@ [FV.FVMAIN_COMPACT]
}
  }
 
-!include OvmfPkg/FvmainCompactScratchEnd.fdf.inc
+!include OvmfPkg/inc/FvmainCompactScratchEnd.fdf.inc
 
 

 
diff --git a/OvmfPkg/Bhyve/BhyveX64.fdf b/OvmfPkg/Bhyve/BhyveX64.fdf
index e8227f865f75..d22064967084 100644
--- a/OvmfPkg/Bhyve/BhyveX64.fdf
+++ b/OvmfPkg/Bhyve/BhyveX64.fdf
@@ -24,7 +24,7 @@ [FD.BHYVE]
 BlockSize = $(BLOCK_SIZE)
 NumBlocks = $(FW_BLOCKS)
 
-!include VarStore.fdf.inc
+!include OvmfPkg/inc/VarStore.fdf.inc
 
 $(VARS_SIZE)|$(FVMAIN_SIZE)
 FV = FVMAIN_COMPACT
@@ -43,7 +43,7 @@ [FD.BHYVE_VARS]
 BlockSize = $(BLOCK_SIZE)
 NumBlocks = $(VARS_BLOCKS)
 
-!include VarStore.fdf.inc
+!include OvmfPkg/inc/VarStore.fdf.inc
 
 [FD.BHYVE_CODE]
 BaseAddress   = $(CODE_BASE_ADDRESS)
@@ -368,7 +368,7 @@ [FV.FVMAIN_COMPACT]
}
  }
 
-!include FvmainCompactScratchEnd.fdf.inc
+!include OvmfPkg/inc/FvmainCompactScratchEnd.fdf.inc
 
 

 
diff --git a/OvmfPkg/CloudHv/CloudHvX64.fdf b/OvmfPkg/CloudHv/CloudHvX64.fdf
index 23296f4bfeae..a45cfa050403 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.fdf
+++ b/OvmfPkg/CloudHv/CloudHvX64.fdf
@@ -378,7 +378,7 @@ [FV.FVMAIN_COMPACT]
}
  }
 
-!include OvmfPkg/FvmainCompactScratchEnd.fdf.inc
+!include OvmfPkg/inc/FvmainCompactScratchEnd.fdf.inc
 
 

 
diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.fdf b/OvmfPkg/IntelTdx/IntelTdxX64.fdf
index 6923eb883113..f594e88d62e7 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.fdf
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.fdf
@@ -11,7 +11,7 @@
 

 
 [Defines]
-!include OvmfPkg/OvmfPkgDefines.fdf.inc
+!include OvmfPkg/inc/OvmfPkgDefines.fdf.inc
 
 #
 # Build the variable store and the firmware code as one unified flash device
@@ -24,7 +24,7 @@ [FD.OVMF]
 BlockSize = $(BLOCK_SIZE)
 NumBlocks = $(FW_BLOCKS)
 
-!include OvmfPkg/VarStore.fdf.inc
+!include OvmfPkg/inc/VarStore.fdf.inc
 
 $(VARS_SIZE)|$(FVMAIN_SIZE)
 FV = FVMAIN_COMPACT
@@ -43,7 +43,7 @@ [FD.OVMF_VARS]
 BlockSize = $(BLOCK_SIZE)
 NumBlocks = $(VARS_BLOCKS)
 
-!include OvmfPkg/VarStore.fdf.inc
+!include OvmfPkg/inc/VarStore.fdf.inc
 
 [FD.OVMF_CODE]
 BaseAddress   = $(CODE_BASE_ADDRESS)
@@ -332,7 +332,7 @@ [FV.FVMAIN_COMPACT]
}
  }
 
-# !include OvmfPkg/FvmainCompactScratchEnd.fdf.inc
+# !include OvmfPkg/inc/FvmainCompactScratchEnd.fdf.inc
 
 

 
diff --git a/OvmfPkg/Microvm/MicrovmX64.fdf b/OvmfPkg/Microvm/MicrovmX64.fdf
index 380ba3a36883..a9a0944bb91d 100644
--- a/OvmfPkg/Microvm/MicrovmX64.fdf
+++ b/OvmfPkg/Microvm/MicrovmX64.fdf
@@ -11,7 +11,7 @@
 

 
 [Defines]
-!include OvmfPkg/OvmfPkgDefines.fdf.inc
+!incl

[edk2-devel] [PATCH 1/3] OvmfPkg: move dsc and fdf include snippets for TPM support to inc subdir

2022-12-02 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/{ => inc}/OvmfTpmComponentsDxe.dsc.inc |  0
 OvmfPkg/{ => inc}/OvmfTpmComponentsPei.dsc.inc |  0
 OvmfPkg/{ => inc}/OvmfTpmDefines.dsc.inc   |  0
 OvmfPkg/{ => inc}/OvmfTpmLibs.dsc.inc  |  0
 OvmfPkg/{ => inc}/OvmfTpmPcds.dsc.inc  |  0
 OvmfPkg/{ => inc}/OvmfTpmPcdsHii.dsc.inc   |  0
 OvmfPkg/{ => inc}/OvmfTpmSecurityStub.dsc.inc  |  0
 OvmfPkg/AmdSev/AmdSevX64.dsc   | 14 +++---
 OvmfPkg/CloudHv/CloudHvX64.dsc | 14 +++---
 OvmfPkg/Microvm/MicrovmX64.dsc |  2 +-
 OvmfPkg/OvmfPkgIa32.dsc| 14 +++---
 OvmfPkg/OvmfPkgIa32X64.dsc | 14 +++---
 OvmfPkg/OvmfPkgX64.dsc | 14 +++---
 OvmfPkg/AmdSev/AmdSevX64.fdf   |  4 ++--
 OvmfPkg/CloudHv/CloudHvX64.fdf |  4 ++--
 OvmfPkg/OvmfPkgIa32.fdf|  4 ++--
 OvmfPkg/OvmfPkgIa32X64.fdf |  4 ++--
 OvmfPkg/OvmfPkgX64.fdf |  4 ++--
 OvmfPkg/{ => inc}/OvmfTpmDxe.fdf.inc   |  0
 OvmfPkg/{ => inc}/OvmfTpmPei.fdf.inc   |  0
 20 files changed, 46 insertions(+), 46 deletions(-)
 rename OvmfPkg/{ => inc}/OvmfTpmComponentsDxe.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmComponentsPei.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmDefines.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmLibs.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmPcds.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmPcdsHii.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmSecurityStub.dsc.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmDxe.fdf.inc (100%)
 rename OvmfPkg/{ => inc}/OvmfTpmPei.fdf.inc (100%)

diff --git a/OvmfPkg/OvmfTpmComponentsDxe.dsc.inc 
b/OvmfPkg/inc/OvmfTpmComponentsDxe.dsc.inc
similarity index 100%
rename from OvmfPkg/OvmfTpmComponentsDxe.dsc.inc
rename to OvmfPkg/inc/OvmfTpmComponentsDxe.dsc.inc
diff --git a/OvmfPkg/OvmfTpmComponentsPei.dsc.inc 
b/OvmfPkg/inc/OvmfTpmComponentsPei.dsc.inc
similarity index 100%
rename from OvmfPkg/OvmfTpmComponentsPei.dsc.inc
rename to OvmfPkg/inc/OvmfTpmComponentsPei.dsc.inc
diff --git a/OvmfPkg/OvmfTpmDefines.dsc.inc b/OvmfPkg/inc/OvmfTpmDefines.dsc.inc
similarity index 100%
rename from OvmfPkg/OvmfTpmDefines.dsc.inc
rename to OvmfPkg/inc/OvmfTpmDefines.dsc.inc
diff --git a/OvmfPkg/OvmfTpmLibs.dsc.inc b/OvmfPkg/inc/OvmfTpmLibs.dsc.inc
similarity index 100%
rename from OvmfPkg/OvmfTpmLibs.dsc.inc
rename to OvmfPkg/inc/OvmfTpmLibs.dsc.inc
diff --git a/OvmfPkg/OvmfTpmPcds.dsc.inc b/OvmfPkg/inc/OvmfTpmPcds.dsc.inc
similarity index 100%
rename from OvmfPkg/OvmfTpmPcds.dsc.inc
rename to OvmfPkg/inc/OvmfTpmPcds.dsc.inc
diff --git a/OvmfPkg/OvmfTpmPcdsHii.dsc.inc b/OvmfPkg/inc/OvmfTpmPcdsHii.dsc.inc
similarity index 100%
rename from OvmfPkg/OvmfTpmPcdsHii.dsc.inc
rename to OvmfPkg/inc/OvmfTpmPcdsHii.dsc.inc
diff --git a/OvmfPkg/OvmfTpmSecurityStub.dsc.inc 
b/OvmfPkg/inc/OvmfTpmSecurityStub.dsc.inc
similarity index 100%
rename from OvmfPkg/OvmfTpmSecurityStub.dsc.inc
rename to OvmfPkg/inc/OvmfTpmSecurityStub.dsc.inc
diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index 8f7cae787e97..3c32c27095e0 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -33,7 +33,7 @@ [Defines]
   #
   DEFINE SOURCE_DEBUG_ENABLE = FALSE
 
-!include OvmfPkg/OvmfTpmDefines.dsc.inc
+!include OvmfPkg/inc/OvmfTpmDefines.dsc.inc
 
   #
   # Shell can be useful for debugging but should not be enabled for production
@@ -200,7 +200,7 @@ [LibraryClasses]
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
   
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
 
-!include OvmfPkg/OvmfTpmLibs.dsc.inc
+!include OvmfPkg/inc/OvmfTpmLibs.dsc.inc
 
 [LibraryClasses.common]
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
@@ -527,12 +527,12 @@ [PcdsDynamicDefault]
   # Set ConfidentialComputing defaults
   gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0
 
-!include OvmfPkg/OvmfTpmPcds.dsc.inc
+!include OvmfPkg/inc/OvmfTpmPcds.dsc.inc
 
   gEfiMdePkgTokenSpaceGuid.PcdFSBClock|10
 
 [PcdsDynamicHii]
-!include OvmfPkg/OvmfTpmPcdsHii.dsc.inc
+!include OvmfPkg/inc/OvmfTpmPcdsHii.dsc.inc
 
 

 #
@@ -573,7 +573,7 @@ [Components]
   UefiCpuPkg/CpuMpPei/CpuMpPei.inf
   OvmfPkg/AmdSev/SecretPei/SecretPei.inf
 
-!include OvmfPkg/OvmfTpmComponentsPei.dsc.inc
+!include OvmfPkg/inc/OvmfTpmComponentsPei.dsc.inc
 
   #
   # DXE Phase modules
@@ -595,7 +595,7 @@ [Components]
 
   MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
 
-!include OvmfPkg/OvmfTpmSecurityStub.dsc.inc
+!include OvmfPkg/inc/OvmfTpmSecurityStub.dsc.inc
   }
 
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
@@ -766,4 +766,4 @@ [Components]
   #
   # TPM support
   #
-!

Re: [edk2-devel] Subject: [PATCH ovmf 2/5] MdePkg: Add AMD SEV features to PcdConfidentialComputingGuestAttr

2022-12-02 Thread Gerd Hoffmann
On Fri, Dec 02, 2022 at 11:26:56PM +1100, Alexey Kardashevskiy wrote:
> 
> 
> On 2/12/22 01:47, Tom Lendacky wrote:
> > Added the subject as somehow it didn't get set.
> > 
> > On 11/30/22 20:35, Alexey Kardashevskiy wrote:
> > > Date: Tue, 22 Nov 2022 16:12:55 +1100
> > > Subject: [PATCH ovmf 2/5] MdePkg: Add AMD SEV features to
> > >   PcdConfidentialComputingGuestAttr
> > > 
> > > PcdConfidentialComputingGuestAttr so far only contained an SEV mode bit
> > > but there are more other features which do not translate to levels
> > > such as DebugSwap or SecureTsc.
> > > 
> > > This adds the features mask and the DebugSwap feature bit to a PCD.
> > > 
> > > Signed-off-by: Alexey Kardashevskiy 
> > > ---
> > >   MdePkg/Include/ConfidentialComputingGuestAttr.h | 5 -
> > >   1 file changed, 4 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/MdePkg/Include/ConfidentialComputingGuestAttr.h
> > > b/MdePkg/Include/ConfidentialComputingGuestAttr.h
> > > index 44e6df800207..1fd09a51ea52 100644
> > > --- a/MdePkg/Include/ConfidentialComputingGuestAttr.h
> > > +++ b/MdePkg/Include/ConfidentialComputingGuestAttr.h
> > > @@ -26,12 +26,15 @@ typedef enum {
> > >     CCAttrAmdSev    = 0x100,
> > >     CCAttrAmdSevEs  = 0x101,
> > >     CCAttrAmdSevSnp = 0x102,
> > > +  CCAttrAmdSevFeatureMask  = 0x,
> > 
> > The PCD for this is 64-bits, should this be 0x?
> 
> True but does not that really depend on how greedy I am? :) For now I like
> 16bits and leave the rest for everyone else.

If we want add feature bits to that PCD it should IMHO not be
AmdSev-specific, i.e. we should have something along the lines of:

CCAttrTypeMask 0x
CCAttrFeatureMask  0x

Alternatively use another pcd for the feature bits.

take care,
  Gerd



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




Re: [edk2-devel] Subject: [PATCH ovmf 2/5] MdePkg: Add AMD SEV features to PcdConfidentialComputingGuestAttr

2022-12-02 Thread Alexey Kardashevskiy via groups.io




On 2/12/22 01:47, Tom Lendacky wrote:

Added the subject as somehow it didn't get set.

On 11/30/22 20:35, Alexey Kardashevskiy wrote:

Date: Tue, 22 Nov 2022 16:12:55 +1100
Subject: [PATCH ovmf 2/5] MdePkg: Add AMD SEV features to
  PcdConfidentialComputingGuestAttr

PcdConfidentialComputingGuestAttr so far only contained an SEV mode bit
but there are more other features which do not translate to levels
such as DebugSwap or SecureTsc.

This adds the features mask and the DebugSwap feature bit to a PCD.

Signed-off-by: Alexey Kardashevskiy 
---
  MdePkg/Include/ConfidentialComputingGuestAttr.h | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/ConfidentialComputingGuestAttr.h 
b/MdePkg/Include/ConfidentialComputingGuestAttr.h

index 44e6df800207..1fd09a51ea52 100644
--- a/MdePkg/Include/ConfidentialComputingGuestAttr.h
+++ b/MdePkg/Include/ConfidentialComputingGuestAttr.h
@@ -26,12 +26,15 @@ typedef enum {
    CCAttrAmdSev    = 0x100,
    CCAttrAmdSevEs  = 0x101,
    CCAttrAmdSevSnp = 0x102,
+  CCAttrAmdSevFeatureMask  = 0x,


The PCD for this is 64-bits, should this be 0x?


True but does not that really depend on how greedy I am? :) For now I 
like 16bits and leave the rest for everyone else.





--
Alexey


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96893): https://edk2.groups.io/g/devel/message/96893
Mute This Topic: https://groups.io/mt/95383603/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/3] UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support

2022-12-02 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Hi Richard,
Attach the changes for GCC build for your reference.

Regards,
Abner

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Michael
> Brown via groups.io
> Sent: Friday, December 2, 2022 6:09 PM
> To: devel@edk2.groups.io; richar...@ami.com
> Cc: Andrew Fish ; Leif Lindholm
> ; Michael D Kinney
> ; Michael Kubacki
> ; Zhiguang Liu ;
> Liming Gao ; TonyLo [羅金松]
> 
> Subject: Re: [edk2-devel] [PATCH 1/3] UsbNetworkPkg/UsbRndis: Add USB
> RNDIS devices support
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> On 03/10/2022 10:26, RichardHo [何明忠] via groups.io wrote:
> > diff --git a/UsbNetworkPkg/NetworkCommon/DriverBinding.h
> b/UsbNetworkPkg/NetworkCommon/DriverBinding.h
> > new file mode 100644
> > index 00..29f1f967f5
> > --- /dev/null
> > +++ b/UsbNetworkPkg/NetworkCommon/DriverBinding.h
> 
> > +VOID
> > +UndiApiEntry (
> > +  IN  UINT64  Cdb
> > +  );
> 
> Needs an EFIAPI modifier, i.e.
> 
> VOID
> EFIAPI
> UndiApiEntry (
>IN  UINT64  Cdb
>);
> 
> to avoid runtime failures when using a non-Microsoft compiler.
> 
> > diff --git a/UsbNetworkPkg/NetworkCommon/PxeFunction.c
> b/UsbNetworkPkg/NetworkCommon/PxeFunction.c
> > new file mode 100644
> > index 00..f6505f7018
> > --- /dev/null
> > +++ b/UsbNetworkPkg/NetworkCommon/PxeFunction.c
> > +/**
> > +  UNDI API table entry.
> > +
> > +  @param[in]  Cdb  A pointer to the command descriptor block.
> > +
> > +**/
> > +VOID
> > +UndiApiEntry (
> > +  IN  UINT64  Cdb
> > +  )
> 
> As above:
> 
> VOID
> EFIAPI
> UndiApiEntry (
>IN  UINT64  Cdb
>)
> 
> Thanks,
> 
> Michael
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96892): https://edk2.groups.io/g/devel/message/96892
Mute This Topic: https://groups.io/mt/94086820/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/3] UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support

2022-12-02 Thread RichardHo [何明忠] via groups . io
Hi Michael,

Thanks for your response. I will fixed it next.

Thanks,
Richard

-Original Message-
From: Michael Brown 
Sent: 2022年12月2日 6:09 PM
To: devel@edk2.groups.io; Richard Ho (何明忠) 
Cc: Andrew Fish ; Leif Lindholm ; 
Michael D Kinney ; Michael Kubacki 
; Zhiguang Liu ; Liming 
Gao ; Tony Lo (羅金松) 
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH 1/3] UsbNetworkPkg/UsbRndis: Add 
USB RNDIS devices support


**CAUTION: The e-mail below is from an external source. Please exercise caution 
before opening attachments, clicking links, or following guidance.**

On 03/10/2022 10:26, RichardHo [何明忠] via groups.io wrote:
> diff --git a/UsbNetworkPkg/NetworkCommon/DriverBinding.h 
> b/UsbNetworkPkg/NetworkCommon/DriverBinding.h
> new file mode 100644
> index 00..29f1f967f5
> --- /dev/null
> +++ b/UsbNetworkPkg/NetworkCommon/DriverBinding.h

> +VOID
> +UndiApiEntry (
> +  IN  UINT64  Cdb
> +  );

Needs an EFIAPI modifier, i.e.

VOID
EFIAPI
UndiApiEntry (
   IN  UINT64  Cdb
   );

to avoid runtime failures when using a non-Microsoft compiler.

> diff --git a/UsbNetworkPkg/NetworkCommon/PxeFunction.c 
> b/UsbNetworkPkg/NetworkCommon/PxeFunction.c
> new file mode 100644
> index 00..f6505f7018
> --- /dev/null
> +++ b/UsbNetworkPkg/NetworkCommon/PxeFunction.c
> +/**
> +  UNDI API table entry.
> +
> +  @param[in]  Cdb  A pointer to the command descriptor block.
> +
> +**/
> +VOID
> +UndiApiEntry (
> +  IN  UINT64  Cdb
> +  )

As above:

VOID
EFIAPI
UndiApiEntry (
   IN  UINT64  Cdb
   )

Thanks,

Michael
-The information contained in this message may be confidential and proprietary 
to American Megatrends (AMI). This communication is intended to be read only by 
the individual or entity to whom it is addressed or by their designee. If the 
reader of this message is not the intended recipient, you are on notice that 
any distribution of this message, in any form, is strictly prohibited. Please 
promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and 
then delete or destroy all copies of the transmission.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96891): https://edk2.groups.io/g/devel/message/96891
Mute This Topic: https://groups.io/mt/94086820/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/3] UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support

2022-12-02 Thread RichardHo [何明忠] via groups . io
Hi Rebecca,

Thanks for your response. I will fixed it next.

Thanks,
Richard

-Original Message-
From: Rebecca Cran 
Sent: 2022年12月1日 11:47 PM
To: devel@edk2.groups.io; Richard Ho (何明忠) 
Cc: Andrew Fish ; Leif Lindholm ; 
Michael D Kinney ; Michael Kubacki 
; Zhiguang Liu ; Liming 
Gao ; Tony Lo (羅金松) 
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH 1/3] UsbNetworkPkg/UsbRndis: Add 
USB RNDIS devices support


**CAUTION: The e-mail below is from an external source. Please exercise caution 
before opening attachments, clicking links, or following guidance.**

On 10/3/22 03:26, RichardHo [何明忠] via groups.io wrote:

> diff --git a/UsbNetworkPkg/UsbRndis/UsbRndisFunction.c
> b/UsbNetworkPkg/UsbRndis/UsbRndisFunction.c
> new file mode 100644
> index 00..5db95b284c
> --- /dev/null
> +++ b/UsbNetworkPkg/UsbRndis/UsbRndisFunction.c

> +/**
> +  This function is called when UndiShutdown is invoked.
> +
> +  @param[in]  Cdb  A pointer to the command descriptor block.
> +  @param[in]  Nic  A pointer to the Network interface controller data.
> +
> +  @retval EFI_SUCCESS The request executed successfully.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +RndisUndiShutdown (
> +  IN  PXE_CDB   *Cdb,
> +  IN  NIC_DATA  *Nic
> +  )
> +{
> +  EDKII_USB_ETHERNET_PROTOCOL  *UsbEthDriver   = Nic->UsbEth;
> +  USB_RNDIS_DEVICE *UsbRndisDevice = USB_RNDIS_DEVICE_FROM_THIS 
> (UsbEthDriver);
> +  REMOTE_NDIS_HALT_MSG RndisHltMsg;
> +  EFI_STATUS   Status;
> +
> +  DEBUG ((DEBUG_INFO, "RndisUndiShutdown\n"));

According to the edk2 coding style, you should declare and initialize variables 
separately.

+/**
+  This is a dummy function which just returns. Unimplimented
EDKII_USB_ETHERNET_PROTOCOL functions
+  point to this function.

Typo. Should be "Unimplemented".

diff --git a/UsbNetworkPkg/UsbCdcNcm/UsbCdcNcm.h
b/UsbNetworkPkg/UsbCdcNcm/UsbCdcNcm.h
index 98eef820d895..9d607da72051 100644
--- a/UsbNetworkPkg/UsbCdcNcm/UsbCdcNcm.h
+++ b/UsbNetworkPkg/UsbCdcNcm/UsbCdcNcm.h

+#define USB_ETH_FRAME_SIZE 0x5F2  // frome network stack

Typo.




--
Rebecca Cran
-The information contained in this message may be confidential and proprietary 
to American Megatrends (AMI). This communication is intended to be read only by 
the individual or entity to whom it is addressed or by their designee. If the 
reader of this message is not the intended recipient, you are on notice that 
any distribution of this message, in any form, is strictly prohibited. Please 
promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and 
then delete or destroy all copies of the transmission.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96890): https://edk2.groups.io/g/devel/message/96890
Mute This Topic: https://groups.io/mt/94086820/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/3] UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support

2022-12-02 Thread Michael Brown

On 03/10/2022 10:26, RichardHo [何明忠] via groups.io wrote:

diff --git a/UsbNetworkPkg/NetworkCommon/DriverBinding.h 
b/UsbNetworkPkg/NetworkCommon/DriverBinding.h
new file mode 100644
index 00..29f1f967f5
--- /dev/null
+++ b/UsbNetworkPkg/NetworkCommon/DriverBinding.h



+VOID
+UndiApiEntry (
+  IN  UINT64  Cdb
+  );


Needs an EFIAPI modifier, i.e.

VOID
EFIAPI
UndiApiEntry (
  IN  UINT64  Cdb
  );

to avoid runtime failures when using a non-Microsoft compiler.


diff --git a/UsbNetworkPkg/NetworkCommon/PxeFunction.c 
b/UsbNetworkPkg/NetworkCommon/PxeFunction.c
new file mode 100644
index 00..f6505f7018
--- /dev/null
+++ b/UsbNetworkPkg/NetworkCommon/PxeFunction.c
+/**
+  UNDI API table entry.
+
+  @param[in]  Cdb  A pointer to the command descriptor block.
+
+**/
+VOID
+UndiApiEntry (
+  IN  UINT64  Cdb
+  )


As above:

VOID
EFIAPI
UndiApiEntry (
  IN  UINT64  Cdb
  )

Thanks,

Michael


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




回复: [edk2-devel] [PATCH] MdePkg/UnitTestHostBaseLib: Remove HOST_APPLICATION limitation

2022-12-02 Thread gaoliming via groups.io
Zhiguang:
  Can you explain more about the emulator usage model for this library?

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Zhiguang Liu
> 发送时间: 2022年12月2日 14:25
> 收件人: devel@edk2.groups.io
> 抄送: Zhiguang Liu ; Michael D Kinney
> ; Liming Gao ;
> Ray Ni 
> 主题: [edk2-devel] [PATCH] MdePkg/UnitTestHostBaseLib: Remove
> HOST_APPLICATION limitation
> 
> Remove HOST_APPLICATION limitation for UnitTestHostBaseLib, so that
> this library can be used as BaseLib by Emulator.
> Also, add some missing files
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Signed-off-by: Ray Ni 
> ---
>  MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
> b/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
> index 09a610c31c..fefa2e79f6 100644
> --- a/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
> +++ b/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
> @@ -1,7 +1,7 @@
>  ## @file
>  #  Base Library implementation for use with host based unit tests.
>  #
> -#  Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
> +#  Copyright (c) 2007 - 2022, 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.
> @@ -18,7 +18,7 @@
>FILE_GUID  =
> 9555A0D3-09BA-46C4-A51A-45198E3C765E
>MODULE_TYPE= BASE
>VERSION_STRING = 1.1
> -  LIBRARY_CLASS  = BaseLib|HOST_APPLICATION
> +  LIBRARY_CLASS  = BaseLib
>LIBRARY_CLASS  =
> UnitTestHostBaseLib|HOST_APPLICATION
> 
>  #
> @@ -128,6 +128,7 @@
>X86RdRand.c
>X86SpeculationBarrier.c
>X86UnitTestHost.c
> +  IntelTdxNull.c
> 
>  [Sources.X64]
>X64/LongJump.nasm
> @@ -168,6 +169,7 @@
>X64/RdRand.nasm
>ChkStkGcc.c  | GCC
>X86UnitTestHost.c
> +  IntelTdxNull.c
> 
>  [Sources.EBC]
>Ebc/CpuBreakpoint.c
> --
> 2.31.1.windows.1
> 
> 
> 
> 
> 





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