Date   

[PATCH v10 04/17] OvmfPkg: CI: use Python version from defaults template

Oliver Steffen
 

Use the default Python version from the defaults template
(.azurepipelines/templates/defaults.yml) in the Windows and
Linux CI jobs.

Previous changes to the CI job templates make it necessary
to specify a version number, if Python shall be pulled
at CI runtime.

Signed-off-by: Oliver Steffen <osteffen@...>
---
OvmfPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml | 4 ++++
OvmfPkg/PlatformCI/.azurepipelines/Windows-VS2019.yml | 5 +++++
2 files changed, 9 insertions(+)

diff --git a/OvmfPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
b/OvmfPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
index 7160d95f7e04..6dd90711ac70 100644
--- a/OvmfPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
+++ b/OvmfPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
@@ -15,6 +15,9 @@ pr:
- master
- stable/*

+variables:
+ - template: ../../../.azurepipelines/templates/defaults.yml
+
jobs:
- job: Platform_CI
variables:
@@ -187,6 +190,7 @@ jobs:
build_file: $(Build.File)
build_flags: $(Build.Flags)
run_flags: $(Run.Flags)
+ usePythonVersion: ${{ variables.default_python_version }}
extra_install_step:
- bash: sudo apt-get install qemu
displayName: Install qemu
diff --git a/OvmfPkg/PlatformCI/.azurepipelines/Windows-VS2019.yml
b/OvmfPkg/PlatformCI/.azurepipelines/Windows-VS2019.yml
index 7d6344d6383d..7e63f419b26b 100644
--- a/OvmfPkg/PlatformCI/.azurepipelines/Windows-VS2019.yml
+++ b/OvmfPkg/PlatformCI/.azurepipelines/Windows-VS2019.yml
@@ -14,6 +14,10 @@ trigger:
pr:
- master
- stable/*
+
+variables:
+ - template: ../../../.azurepipelines/templates/defaults.yml
+
jobs:
- job: Platform_CI
variables:
@@ -133,6 +137,7 @@ jobs:
build_file: $(Build.File)
build_flags: $(Build.Flags)
run_flags: $(Run.Flags)
+ usePythonVersion: ${{ variables.default_python_version }}
extra_install_step:
- powershell: choco install qemu --version=2021.5.5;
Write-Host "##vso[task.prependpath]c:\Program Files\qemu"
displayName: Install QEMU and Set QEMU on path # friendly
name displayed in the UI
--
2.38.1


[PATCH v10 03/17] EmulatorPkg: CI: use Python version from defaults template

Oliver Steffen
 

Use the default Python version from the defaults template
(.azurepipelines/templates/defaults.yml) in the Windows and
Linux CI jobs.

Previous changes to the CI job templates make it necessary
to specify a version number, if Python shall be pulled
at CI runtime.

Signed-off-by: Oliver Steffen <osteffen@...>
---
EmulatorPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml | 5 +++++
EmulatorPkg/PlatformCI/.azurepipelines/Windows-VS2019.yml | 4 ++++
2 files changed, 9 insertions(+)

diff --git a/EmulatorPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
b/EmulatorPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
index 416c15e70840..a32c57d4aab4 100644
--- a/EmulatorPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
+++ b/EmulatorPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
@@ -15,6 +15,10 @@ trigger:
pr:
- master
- stable/*
+
+variables:
+ - template: ../../../.azurepipelines/templates/defaults.yml
+
jobs:
- job: Platform_CI
variables:
@@ -85,3 +89,4 @@ jobs:
build_file: $(Build.File)
build_flags: $(Build.Flags)
run_flags: $(Run.Flags)
+ usePythonVersion: ${{ variables.default_python_version }}
diff --git a/EmulatorPkg/PlatformCI/.azurepipelines/Windows-VS2019.yml
b/EmulatorPkg/PlatformCI/.azurepipelines/Windows-VS2019.yml
index e7ead06ae266..09960e7c7a6e 100644
--- a/EmulatorPkg/PlatformCI/.azurepipelines/Windows-VS2019.yml
+++ b/EmulatorPkg/PlatformCI/.azurepipelines/Windows-VS2019.yml
@@ -16,6 +16,9 @@ pr:
- master
- stable/*

+variables:
+ - template: ../../../.azurepipelines/templates/defaults.yml
+
jobs:
- job: Platform_CI
variables:
@@ -128,3 +131,4 @@ jobs:
build_file: $(Build.File)
build_flags: $(Build.Flags)
run_flags: $(Run.Flags)
+ usePythonVersion: ${{ variables.default_python_version }}
--
2.38.1


[PATCH v10 02/17] ArmVirtPkg: CI: use Python version from defaults template

Oliver Steffen
 

Use the default Python version from the defaults template
(.azurepipelines/templates/defaults.yml) in the Windows and
Linux CI jobs.

Previous changes to the CI job templates make it necessary
to specify a version number, if Python shall be pulled
at CI runtime.

Signed-off-by: Oliver Steffen <osteffen@...>
---
ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
index b07e3199f143..5a0e589ed4a7 100644
--- a/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
+++ b/ArmVirtPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
@@ -15,6 +15,9 @@ pr:
- master
- stable/*

+variables:
+ - template: ../../../.azurepipelines/templates/defaults.yml
+
jobs:
- job: Platform_CI
variables:
@@ -85,6 +88,7 @@ jobs:
build_file: $(Build.File)
build_flags: $(Build.Flags)
run_flags: $(Run.Flags)
+ usePythonVersion: ${{ variables.default_python_version }}
extra_install_step:
- bash: sudo apt-get install qemu
displayName: Install qemu
--
2.38.1


[PATCH v10 01/17] CI: make Python version configurable

Oliver Steffen
 

Add a new parameter "usePythonVersion" to the CI job templates.
This makes it possible to specify the version of Python to use.
The default value is '', in which case Python will not be downloaded
at runtime and the one provided by the VM/container image will be used.

Additionally, add a template .azurepipelines/templates/defaults.yml,
from which the default Pyhton version string can be obtained.

Signed-off-by: Oliver Steffen <osteffen@...>
---
.azurepipelines/Ubuntu-GCC5.yml | 4 ++++
.azurepipelines/Windows-VS2019.yml | 4 ++++
.azurepipelines/templates/defaults.yml | 11 +++++++++++
.../templates/platform-build-run-steps.yml | 6 +++++-
.azurepipelines/templates/pr-gate-build-job.yml | 2 ++
.azurepipelines/templates/pr-gate-steps.yml | 6 ++++--
6 files changed, 30 insertions(+), 3 deletions(-)
create mode 100644 .azurepipelines/templates/defaults.yml

diff --git a/.azurepipelines/Ubuntu-GCC5.yml b/.azurepipelines/Ubuntu-GCC5.yml
index 1acd8d2a46a7..4ed6cb601b8e 100644
--- a/.azurepipelines/Ubuntu-GCC5.yml
+++ b/.azurepipelines/Ubuntu-GCC5.yml
@@ -13,10 +13,14 @@ 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'
arch_list: "IA32,X64,ARM,AARCH64,RISCV64,LOONGARCH64"
+ usePythonVersion: ${{ variables.default_python_version }}

diff --git a/.azurepipelines/Windows-VS2019.yml
b/.azurepipelines/Windows-VS2019.yml
index e4bd4b1d2283..89bccde82575 100644
--- a/.azurepipelines/Windows-VS2019.yml
+++ b/.azurepipelines/Windows-VS2019.yml
@@ -12,9 +12,13 @@ pr:
- master
- stable/*

+variables:
+ - template: templates/defaults.yml
+
jobs:
- template: templates/pr-gate-build-job.yml
parameters:
tool_chain_tag: 'VS2019'
vm_image: 'windows-2019'
arch_list: "IA32,X64"
+ usePythonVersion: ${{ variables.default_python_version }}
diff --git a/.azurepipelines/templates/defaults.yml
b/.azurepipelines/templates/defaults.yml
new file mode 100644
index 000000000000..b4909448bdea
--- /dev/null
+++ b/.azurepipelines/templates/defaults.yml
@@ -0,0 +1,11 @@
+## @file
+# File templates/default.yml
+#
+# template file containing common default values
+#
+# Copyright (c) Red Hat, Inc.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+variables:
+ default_python_version: ">=3.10.6"
diff --git a/.azurepipelines/templates/platform-build-run-steps.yml
b/.azurepipelines/templates/platform-build-run-steps.yml
index 40a31a509fc5..8803d80cf51c 100644
--- a/.azurepipelines/templates/platform-build-run-steps.yml
+++ b/.azurepipelines/templates/platform-build-run-steps.yml
@@ -34,6 +34,9 @@ parameters:
- name: extra_install_step
type: stepList
default: []
+- name: usePythonVersion
+ type: string
+ default: ''

steps:
- checkout: self
@@ -42,8 +45,9 @@ steps:

- task: UsePythonVersion@0
inputs:
- versionSpec: ">=3.10.6"
+ versionSpec: ${{ parameters.usePythonVersion }}
architecture: "x64"
+ condition: ne('${{ parameters.usePythonVersion }}', '')

- script: pip install -r pip-requirements.txt --upgrade
displayName: 'Install/Upgrade pip modules'
diff --git a/.azurepipelines/templates/pr-gate-build-job.yml
b/.azurepipelines/templates/pr-gate-build-job.yml
index 7f88b41dc8d3..f0ef1142da49 100644
--- a/.azurepipelines/templates/pr-gate-build-job.yml
+++ b/.azurepipelines/templates/pr-gate-build-job.yml
@@ -12,6 +12,7 @@ parameters:
tool_chain_tag: ''
vm_image: ''
arch_list: ''
+ usePythonVersion: ''

# Build step
jobs:
@@ -77,3 +78,4 @@ jobs:
build_pkgs: $(Build.Pkgs)
build_targets: $(Build.Targets)
build_archs: ${{ parameters.arch_list }}
+ usePythonVersion: ${{ parameters.usePythonVersion }}
diff --git a/.azurepipelines/templates/pr-gate-steps.yml
b/.azurepipelines/templates/pr-gate-steps.yml
index cb431e53fcd1..27a44c06011c 100644
--- a/.azurepipelines/templates/pr-gate-steps.yml
+++ b/.azurepipelines/templates/pr-gate-steps.yml
@@ -12,6 +12,7 @@ parameters:
build_pkgs: ''
build_targets: ''
build_archs: ''
+ usePythonVersion: ''

steps:
- checkout: self
@@ -20,8 +21,9 @@ steps:

- task: UsePythonVersion@0
inputs:
- versionSpec: '>=3.10.6'
- architecture: 'x64'
+ versionSpec: ${{ parameters.usePythonVersion }}
+ architecture: "x64"
+ condition: ne('${{ parameters.usePythonVersion }}', '')

- script: pip install -r pip-requirements.txt --upgrade
displayName: 'Install/Upgrade pip modules'
--
2.38.1


[PATCH v10 00/17] CI: Use Fedora 35 container for Linux jobs

Oliver Steffen
 

Update CI, run all Linux (aka Ubuntu-GCC5) based jobs in custom
containers. This decouples the CI environment from the virtual machine
images that Azure DevOps provides. The currently used ubuntu-18.04 image
has been deprecated for a while now and will finally be removed on
Dec 1st 2022.

The container image provides the required compiler toolchains and Qemu
for the supported architectures. These are then no longer downloaded at
runtime, avoiding CI failures due to download errors. This approach also
makes it easier to switch to other or newer compilers. It makes the CI
setup independent from the default images that Azure DevOps provides.
It can also help debugging CI problems, because the CI environment
can be reproduced on a local machine.

The container images are hosted on ghcr.io and are automatically
generated using GitHub Actions. The Dockerfiles are maintained in the
Tianocore "containers" repository:
https://github.com/tianocore/containers.

The current image is based on Fedora 35, with gcc 11. Fedora was chosen
because of its fast release cycle which makes it easy to keep the
toolchains up-to-date.

Some further possible changes not included in this series:
- The Tianocore/containers repository provides stack of layered images.
One image for general purpose (build+test) and build-only jobs.
The build+test image is based on the build-only one and adds Qemu,
for the testing job that involve Qemu. The work in the image side
is done, we just need to change the CI setup accordingly.
This patch set uses the build+test images for all jobs.
- Further reduce the number of external dependencies that need to be
downloaded at runtime. Candidates are iasl and nasm, which are already
included in the image but not used yet.

PR: https://github.com/tianocore/edk2/pull/3696

v10:
- Split commits by package
- use ubuntu-22.04 as vm_image (instread of the floating ubuntu-latest)
- some fixups around the Python version template argument and defaults.yml
- fix some commit messages
- add license statement to defaults.yml

v9:
- Drop the "Don't install cspell" patch
- Use explicitly use ubuntu-22.04 as vm_image

v8:
- Use updated container image that contains gcc for LoongArch64.
- Remove ext_dep files for the LoongArch64 gcc.
- Don't change the scopes in .pytool/CISettings.py if running Linux CI
it.
- Split commits that touch multiple packages.
- Use the smaller "build" image for jobs that allow it.
- Add a CI template file as a central place to define the default Python version
and use it where needed.

v7:
- Rebase to latest master branch.
- Use latest Fedora 35 CI image.
- Stop using the ubuntu-18.04 vm_image since this will no longer be available
after Dec 1st. Use ubuntu-latest instead.

v6:
- Include suggestions by Chris Fernald.
- Added a parameter for the container image to the job template, makes usage
of containers optional.
- Added a parameter to configure the Python version to download. Allows
using Python from the VM/container image also.
- Restructure the commits (no further functional changes).

v5:
- Update image

v4:
- Use the latest image from the tianocode/containers repository which
- does not include acpica-tools
- includes Pyhton 3.10

v3:
- Use the latest image from the tianocode/containers repository which
pins down version numbers of gcc, iasl, and nasm in the Dockerfile.

v2:
- Images are now hosted under the Tianocore Organization
https://github.com/tianocore/containers

v1:
- Thread: https://edk2.groups.io/g/devel/message/89058
- Images were hosted at https://github.com/osteffenrh/edk2-build-images

Signed-off-by: Oliver Steffen <osteffen@...>
Acked-by: Ard Biesheuvel <ardb@...>
Acked-by: Gerd Hoffmann <kraxel@...>
Reviewed-by: Chris Fernald <chfernal@...>

Oliver Steffen (17):
CI: make Python version configurable
ArmVirtPkg: CI: use Python version from defaults template
EmulatorPkg: CI: use Python version from defaults template
OvmfPkg: CI: use Python version from defaults template
CI: add ~/.local/bin to PATH (Linux only)
CI: Allow running in a container.
CI: Use Fedora 35 container (Linux only)
ArmVirtPkg: CI: Use Fedora 35 container (Linux only)
EmulatorPkg: CI: Use Fedora 35 container (Linux only)
OvmfPkg: CI: Use Fedora 35 container (Linux only)
.pytool: CISettings.py: don't add scopes for GCC
BaseTools: remove ext_dep files for gcc
ArmVirtPkg: CI: use ubuntu-22.04 vm_image (Linux only)
EmulatorPgk: CI: use ubuntu-22.04 vm_image (Linux only)
OvmfPkg: CI: use ubuntu-22.04 vm_image (Linux only)
CI: use ubuntu-22.04 image (Linux only)
do not merge: modify *.dsc to trigger CI

ArmPkg/ArmPkg.dsc | 1 +
.../ArmCrashDumpDxe/ArmCrashDumpDxe.dsc | 1 +
ArmPlatformPkg/ArmPlatformPkg.dsc | 1 +
ArmVirtPkg/ArmVirtCloudHv.dsc | 1 +
ArmVirtPkg/ArmVirtKvmTool.dsc | 1 +
ArmVirtPkg/ArmVirtQemu.dsc | 1 +
ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 +
ArmVirtPkg/ArmVirtXen.dsc | 1 +
CryptoPkg/CryptoPkg.dsc | 1 +
CryptoPkg/Test/CryptoPkgHostUnitTest.dsc | 1 +
DynamicTablesPkg/DynamicTablesPkg.dsc | 1 +
EmbeddedPkg/EmbeddedPkg.dsc | 1 +
EmulatorPkg/EmulatorPkg.dsc | 1 +
FatPkg/FatPkg.dsc | 1 +
FmpDevicePkg/FmpDevicePkg.dsc | 1 +
FmpDevicePkg/Test/FmpDeviceHostPkgTest.dsc | 1 +
IntelFsp2Pkg/IntelFsp2Pkg.dsc | 1 +
IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc | 1 +
IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc | 1 +
MdeModulePkg/MdeModulePkg.dsc | 1 +
MdeModulePkg/Test/MdeModulePkgHostTest.dsc | 1 +
MdePkg/MdePkg.dsc | 1 +
MdePkg/Test/MdePkgHostTest.dsc | 1 +
NetworkPkg/NetworkPkg.dsc | 1 +
OvmfPkg/AmdSev/AmdSevX64.dsc | 1 +
OvmfPkg/Bhyve/BhyveX64.dsc | 1 +
OvmfPkg/CloudHv/CloudHvX64.dsc | 1 +
OvmfPkg/IntelTdx/IntelTdxX64.dsc | 1 +
OvmfPkg/Microvm/MicrovmX64.dsc | 1 +
OvmfPkg/OvmfPkgIa32.dsc | 1 +
OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
OvmfPkg/OvmfPkgX64.dsc | 1 +
OvmfPkg/OvmfXen.dsc | 1 +
PcAtChipsetPkg/PcAtChipsetPkg.dsc | 1 +
PrmPkg/PrmPkg.dsc | 1 +
PrmPkg/Test/PrmPkgHostTest.dsc | 1 +
RedfishPkg/RedfishPkg.dsc | 1 +
SecurityPkg/SecurityPkg.dsc | 1 +
SecurityPkg/Test/SecurityPkgHostTest.dsc | 1 +
ShellPkg/ShellPkg.dsc | 1 +
SignedCapsulePkg/SignedCapsulePkg.dsc | 1 +
SourceLevelDebugPkg/SourceLevelDebugPkg.dsc | 1 +
StandaloneMmPkg/StandaloneMmPkg.dsc | 1 +
UefiCpuPkg/Test/UefiCpuPkgHostTest.dsc | 1 +
UefiCpuPkg/UefiCpuPkg.dsc | 1 +
UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
.../Test/UnitTestFrameworkPkgHostTest.dsc | 1 +
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dsc | 1 +
.azurepipelines/Ubuntu-GCC5.yml | 4 +++-
.azurepipelines/Windows-VS2019.yml | 4 ++++
.../templates/basetools-build-steps.yml | 9 --------
.azurepipelines/templates/defaults.yml | 11 ++++++++++
.../templates/platform-build-run-steps.yml | 12 +++++++++-
.../templates/pr-gate-build-job.yml | 6 +++++
.azurepipelines/templates/pr-gate-steps.yml | 12 ++++++++--
.pytool/CISettings.py | 9 --------
.../.azurepipelines/Ubuntu-GCC5.yml | 9 ++++----
BaseTools/Bin/gcc_aarch64_linux_ext_dep.yaml | 21 ------------------
BaseTools/Bin/gcc_arm_linux_ext_dep.yaml | 21 ------------------
...gcc_loongarch64_unknown_linux_ext_dep.yaml | 22 -------------------
.../Bin/gcc_riscv64_unknown_ext_dep.yaml | 22 -------------------
.../.azurepipelines/Ubuntu-GCC5.yml | 5 ++++-
.../.azurepipelines/Windows-VS2019.yml | 4 ++++
.../.azurepipelines/Ubuntu-GCC5.yml | 9 ++++----
.../.azurepipelines/Windows-VS2019.yml | 5 +++++
65 files changed, 114 insertions(+), 119 deletions(-)
create mode 100644 .azurepipelines/templates/defaults.yml
delete mode 100644 BaseTools/Bin/gcc_aarch64_linux_ext_dep.yaml
delete mode 100644 BaseTools/Bin/gcc_arm_linux_ext_dep.yaml
delete mode 100644 BaseTools/Bin/gcc_loongarch64_unknown_linux_ext_dep.yaml
delete mode 100644 BaseTools/Bin/gcc_riscv64_unknown_ext_dep.yaml

--
2.38.1


[PATCH 2/4] MdeModulePkg/XhciDxe/Xhci: Don't check for invalid PSIV

Sean Rhodes
 

From: Matt DeVillier <matt.devillier@...>

PSID matching relies on comparing the PSIV against the PortSpeed
value. This patch stops edk2 from checking for a PSIV of 0, as it
is not valid; this reduces the number of register access by
approximately 6 per second.

Cc: Hao A Wu <hao.a.wu@...>
Cc: Ray Ni <ray.ni@...>
Reviewed-by: Sean Rhodes <sean@...>
Signed-off-by: Matt DeVillier <matt.devillier@...>
Change-Id: If15c55ab66d2e7faa832ce8576d2e5b47157cc9a
---
MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 44 ++++++++++++++++-------------
1 file changed, 25 insertions(+), 19 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/Xhc=
iDxe/Xhci.c
index c05431ff30..51ae57db21 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
@@ -371,6 +371,7 @@ XhcGetRootHubPortStatus (
UINT32 TotalPort;=0D
UINTN Index;=0D
UINTN MapSize;=0D
+ UINTN PortSpeed;=0D
EFI_STATUS Status;=0D
USB_DEV_ROUTE ParentRouteChart;=0D
EFI_TPL OldTpl;=0D
@@ -397,32 +398,37 @@ XhcGetRootHubPortStatus (
=0D
State =3D XhcReadOpReg (Xhc, Offset);=0D
=0D
+ PortSpeed =3D (State & XHC_PORTSC_PS) >> 10;=0D
+=0D
//=0D
// According to XHCI 1.1 spec November 2017,=0D
// Section 7.2 xHCI Support Protocol Capability=0D
//=0D
- PortStatus->PortStatus =3D XhcCheckUsbPortSpeedUsedPsic (Xhc, ((State & =
XHC_PORTSC_PS) >> 10));=0D
- if (PortStatus->PortStatus =3D=3D 0) {=0D
- //=0D
- // According to XHCI 1.1 spec November 2017,=0D
- // bit 10~13 of the root port status register identifies the speed of =
the attached device.=0D
- //=0D
- switch ((State & XHC_PORTSC_PS) >> 10) {=0D
- case 2:=0D
- PortStatus->PortStatus |=3D USB_PORT_STAT_LOW_SPEED;=0D
- break;=0D
+ if (PortSpeed > 0) {=0D
+ PortStatus->PortStatus =3D XhcCheckUsbPortSpeedUsedPsic (Xhc, PortSpee=
d);=0D
+ // If no match found in ext cap reg, fall back to PORTSC=0D
+ if (PortStatus->PortStatus =3D=3D 0) {=0D
+ //=0D
+ // According to XHCI 1.1 spec November 2017,=0D
+ // bit 10~13 of the root port status register identifies the speed o=
f the attached device.=0D
+ //=0D
+ switch (PortSpeed) {=0D
+ case 2:=0D
+ PortStatus->PortStatus |=3D USB_PORT_STAT_LOW_SPEED;=0D
+ break;=0D
=0D
- case 3:=0D
- PortStatus->PortStatus |=3D USB_PORT_STAT_HIGH_SPEED;=0D
- break;=0D
+ case 3:=0D
+ PortStatus->PortStatus |=3D USB_PORT_STAT_HIGH_SPEED;=0D
+ break;=0D
=0D
- case 4:=0D
- case 5:=0D
- PortStatus->PortStatus |=3D USB_PORT_STAT_SUPER_SPEED;=0D
- break;=0D
+ case 4:=0D
+ case 5:=0D
+ PortStatus->PortStatus |=3D USB_PORT_STAT_SUPER_SPEED;=0D
+ break;=0D
=0D
- default:=0D
- break;=0D
+ default:=0D
+ break;=0D
+ }=0D
}=0D
}=0D
=0D
--=20
2.37.2


[PATCH 1/4] MdeModulePkg/XhciDxe/XhciReg: Handle incorrect PSIV indices

Sean Rhodes
 

From: Matt DeVillier <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 <hao.a.wu@...>
Cc: Ray Ni <ray.ni@...>
Reviewed-by: Sean Rhodes <sean@...>
Signed-off-by: Matt DeVillier <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 =3D 0;=0D
UsbSpeedIdMap =3D 0;=0D
=0D
- //=0D
- // Check xHCI Supported Protocol Capability, find the PSIV field to matc=
h=0D
- // PortSpeed definition when the Major Revision is 03h.=0D
- //=0D
- if (Xhc->Usb3SupOffset !=3D 0xFFFFFFFF) {=0D
- SpField.Dword =3D XhciPsivGetPsid (Xhc, Xhc->Usb3SupOffset, PortSpeed)=
;=0D
- if (SpField.Dword !=3D 0) {=0D
- //=0D
- // Found the corresponding PORTSC value in PSIV field of USB3 offset=
.=0D
- //=0D
- UsbSpeedIdMap =3D USB_PORT_STAT_SUPER_SPEED;=0D
- }=0D
- }=0D
-=0D
//=0D
// Check xHCI Supported Protocol Capability, find the PSIV field to matc=
h=0D
// PortSpeed definition when the Major Revision is 02h.=0D
//=0D
- if ((UsbSpeedIdMap =3D=3D 0) && (Xhc->Usb2SupOffset !=3D 0xFFFFFFFF)) {=
=0D
+ if (Xhc->Usb2SupOffset !=3D 0xFFFFFFFF) {=0D
SpField.Dword =3D XhciPsivGetPsid (Xhc, Xhc->Usb2SupOffset, PortSpeed)=
;=0D
if (SpField.Dword !=3D 0) {=0D
//=0D
@@ -733,6 +719,12 @@ XhcCheckUsbPortSpeedUsedPsic (
// PSIM shows as default High-speed protocol, apply to High-spee=
d mapping=0D
//=0D
UsbSpeedIdMap =3D USB_PORT_STAT_HIGH_SPEED;=0D
+ } else if (SpField.Data.Psim =3D=3D XHC_SUPPORTED_PROTOCOL_USB2_FU=
LL_SPEED_PSIM) {=0D
+ //=0D
+ // PSIM shows as default Full-speed protocol, return 0=0D
+ // to ensure no port status set=0D
+ //=0D
+ return 0;=0D
}=0D
} else if (SpField.Data.Psie =3D=3D 1) {=0D
//=0D
@@ -750,6 +742,20 @@ XhcCheckUsbPortSpeedUsedPsic (
}=0D
}=0D
=0D
+ //=0D
+ // Check xHCI Supported Protocol Capability, find the PSIV field to matc=
h=0D
+ // PortSpeed definition when the Major Revision is 03h.=0D
+ //=0D
+ if ((UsbSpeedIdMap =3D=3D 0) && (Xhc->Usb3SupOffset !=3D 0xFFFFFFFF)) {=
=0D
+ SpField.Dword =3D XhciPsivGetPsid (Xhc, Xhc->Usb3SupOffset, PortSpeed)=
;=0D
+ if (SpField.Dword !=3D 0) {=0D
+ //=0D
+ // Found the corresponding PORTSC value in PSIV field of USB3 offset=
.=0D
+ //=0D
+ UsbSpeedIdMap =3D USB_PORT_STAT_SUPER_SPEED;=0D
+ }=0D
+ }=0D
+=0D
return UsbSpeedIdMap;=0D
}=0D
=0D
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=0D
#define XHC_SUPPORTED_PROTOCOL_PSI_OFFSET 0x10=0D
#define XHC_SUPPORTED_PROTOCOL_USB2_HIGH_SPEED_PSIM 480=0D
+#define XHC_SUPPORTED_PROTOCOL_USB2_FULL_SPEED_PSIM 12=0D
#define XHC_SUPPORTED_PROTOCOL_USB2_LOW_SPEED_PSIM 1500=0D
=0D
#pragma pack (1)=0D
--=20
2.37.2


[PATCH 3/4] MdeModulePkg/BmBoot: Skip removable media if it is not present

Sean Rhodes
 

From: Matt DeVillier <matt.devillier@...>

Only enumerate devices that have media present.

Cc: Hao A Wu <hao.a.wu@...>
Cc: Ray Ni <ray.ni@...>
Reviewed-by: Sean Rhodes <sean@...>
Signed-off-by: Matt DeVillier <matt.devillier@...>
Change-Id: I78a0b8be3e2f33edce2d43bbdd7670e6174d0ff8
---
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePk=
g/Library/UefiBootManagerLib/BmBoot.c
index 962892d38f..bde22fa659 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -2218,6 +2218,15 @@ BmEnumerateBootOptions (
continue;=0D
}=0D
=0D
+ //=0D
+ // Skip removable media if not present=0D
+ //=0D
+ if ((BlkIo->Media->RemovableMedia =3D=3D TRUE) &&=0D
+ (BlkIo->Media->MediaPresent =3D=3D FALSE))=0D
+ {=0D
+ continue;=0D
+ }=0D
+=0D
Description =3D BmGetBootDescription (Handles[Index]);=0D
BootOptions =3D ReallocatePool (=0D
sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOption=
Count),=0D
--=20
2.37.2


[PATCH 4/4] MdeModulePkg/UsbBusDxe: Adjust the MaxPacketLength to real world values

Sean Rhodes
 

Adjusts the requirements for the MaxPacketLength to match what is seen on
real world devices that do not follow the USB specification.

This fixes enumeration on the multiple USB 3 devices made by SanDisk,
Integral, Kingston and other generic brands.

Cc: Hao A Wu <hao.a.wu@...>
Cc: Ray Ni <ray.ni@...>
Signed-off-by: Sean Rhodes <sean@...>
---
MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c b/MdeModulePkg/Bus/Pci/Xhc=
iDxe/Xhci.c
index 51ae57db21..73bfc62512 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c
@@ -906,19 +906,16 @@ XhcControlTransfer (
return EFI_INVALID_PARAMETER;=0D
}=0D
=0D
- if ((MaximumPacketLength !=3D 8) && (MaximumPacketLength !=3D 16) &&=0D
- (MaximumPacketLength !=3D 32) && (MaximumPacketLength !=3D 64) &&=0D
- (MaximumPacketLength !=3D 512)=0D
- )=0D
- {=0D
+ // Check for valid maximum packet size=0D
+ if ((DeviceSpeed =3D=3D EFI_USB_SPEED_SUPER) && (MaximumPacketLength > 1=
024)) {=0D
return EFI_INVALID_PARAMETER;=0D
}=0D
=0D
- if ((DeviceSpeed =3D=3D EFI_USB_SPEED_LOW) && (MaximumPacketLength !=3D =
8)) {=0D
+ if ((DeviceSpeed =3D=3D EFI_USB_SPEED_HIGH) && (MaximumPacketLength > 51=
2)) {=0D
return EFI_INVALID_PARAMETER;=0D
}=0D
=0D
- if ((DeviceSpeed =3D=3D EFI_USB_SPEED_SUPER) && (MaximumPacketLength !=
=3D 512)) {=0D
+ if ((DeviceSpeed =3D=3D EFI_USB_SPEED_FULL) && (MaximumPacketLength > 64=
)) {=0D
return EFI_INVALID_PARAMETER;=0D
}=0D
=0D
--=20
2.37.2


Re: PATCH v1 1/1 MdePkg: Remove Itanium leftover data structure

Paweł Poławski
 

Hi Mike,

Thank you for the fast response.
I will be waiting for your guidance on this topic.

Btw - I am too new in the EDK2 world to witness this Itanium
deprecation back in 2019. How such process looks like?
If it starts with update in documentation followed by the changes
in the code? How long is the intermediate part where both - new and old
functionality needs to be supported?

Best regards,
Pawel


W dniu 1.12.2022 o 18:01, Michael D Kinney pisze:

Hi Pawel,
Thank you for the patch. I agree this fixes the size issue.
However, this structure and the associated PPI are defined in the PI Spec
and other modules may depend on the structure layout and would have to be
rebuilt after this structure change.
It would be better to have a backwards compatible change here and I do
not have a specific proposal yet that both reduces the size and
preserves backwards compatibility.
There have been examples in the past where we have had to introduce
a new version of a PPI with a new GUID for this type of change.
I will get back to you on this topic in a few days.
Thanks,
Mike

-----Original Message-----
From: Paweł Poławski <ppolawsk@...>
Sent: Thursday, December 1, 2022 7:36 AM
To: devel@edk2.groups.io
Cc: Kinney, Michael D <michael.d.kinney@...>; Gao, Liming <gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>
Subject: [edk2-devel] PATCH v1 1/1 MdePkg: Remove Itanium leftover data structure

Itanium support has been removed from EDK2 aroun 2019.
ITANIUM_HANDOFF_STATUS data structure looks to be
some leftover from that process.

There is also positive sidefect of this data structure removal.
Due to HOB allocation type used in PEI stage there is a limit
how much data about virtual CPU can be hold. This limit result
in only 1024 vCPU can be used by VM.
With Itanium related data structure removed more allocated space
can be used for vCPU data and with current allocation limit
will change from 1024 to around 8k vCPUs.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>

Signed-off-by: Paweł Poławski <ppolawsk@...>
---
MdePkg/Include/Ppi/SecPlatformInformation.h | 44 --------------------
1 file changed, 44 deletions(-)

diff --git a/MdePkg/Include/Ppi/SecPlatformInformation.h b/MdePkg/Include/Ppi/SecPlatformInformation.h
index 02b0711f189e..fbcd205acd96 100644
--- a/MdePkg/Include/Ppi/SecPlatformInformation.h
+++ b/MdePkg/Include/Ppi/SecPlatformInformation.h
@@ -84,49 +84,6 @@ typedef union {

typedef EFI_HEALTH_FLAGS X64_HANDOFF_STATUS;
typedef EFI_HEALTH_FLAGS IA32_HANDOFF_STATUS;
-///
-/// The hand-off status structure for Itanium architecture.
-///
-typedef struct {
- ///
- /// SALE_ENTRY state : 3 = Recovery_Check
- /// and 0 = RESET or Normal_Boot phase.
- ///
- UINT8 BootPhase;
- ///
- /// Firmware status on entry to SALE.
- ///
- UINT8 FWStatus;
- UINT16 Reserved1;
- UINT32 Reserved2;
- ///
- /// Geographically significant unique processor ID assigned by PAL.
- ///
- UINT16 ProcId;
- UINT16 Reserved3;
- UINT8 IdMask;
- UINT8 EidMask;
- UINT16 Reserved4;
- ///
- /// Address to make PAL calls.
- ///
- UINT64 PalCallAddress;
- ///
- /// If the entry state is RECOVERY_CHECK, this contains the PAL_RESET
- /// return address, and if entry state is RESET, this contains
- /// address for PAL_authentication call.
- ///
- UINT64 PalSpecialAddress;
- ///
- /// GR35 from PALE_EXIT state.
- ///
- UINT64 SelfTestStatus;
- ///
- /// GR37 from PALE_EXIT state.
- ///
- UINT64 SelfTestControl;
- UINT64 MemoryBufferRequired;
-} ITANIUM_HANDOFF_STATUS;

///
/// EFI_SEC_PLATFORM_INFORMATION_RECORD.
@@ -134,7 +91,6 @@ typedef struct {
typedef union {
IA32_HANDOFF_STATUS IA32HealthFlags;
X64_HANDOFF_STATUS x64HealthFlags;
- ITANIUM_HANDOFF_STATUS ItaniumHealthFlags;
} EFI_SEC_PLATFORM_INFORMATION_RECORD;

/**
--
2.38.1


Re: [edk2-test][PATCH v1 1/1] uefi-sct/SctPkg: Check for memory below 4G

Sunny Wang
 

Reviewed the patch with Stuart and Edhaya in edk2-test monthly meeting. The patch looks good to me. Thanks, Dimitrije.

Reviewed-by: Sunny Wang <sunny.wang@...>

-----Original Message-----
From: Dimitrije Pavlov <dimitrije.pavlov@...>
Sent: 10 October 2022 03:06
To: devel@edk2.groups.io
Cc: G Edhaya Chandran <Edhaya.Chandran@...>; Jeff Booher-Kaeding <Jeff.Booher-Kaeding@...>; Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>; Sunny Wang <Sunny.Wang@...>
Subject: [edk2-test][PATCH v1 1/1] uefi-sct/SctPkg: Check for memory below 4G

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

Check if there is usable memory below 4 GiB before testing for
allocation without the EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE attribute.

Cc: G Edhaya Chandran <Edhaya.Chandran@...>
Cc: Jeff Booher-Kaeding <Jeff.Booher-Kaeding@...>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>
Cc: Sunny Wang <Sunny.Wang@...>

Signed-off-by: Dimitrije Pavlov <Dimitrije.Pavlov@...>
---
uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PciRootBridgeIo/BlackBoxTest/PciRootBridgeIoBBTestFunction_2.c | 142 +++++++++++++++++++-
1 file changed, 140 insertions(+), 2 deletions(-)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PciRootBridgeIo/BlackBoxTest/PciRootBridgeIoBBTestFunction_2.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PciRootBridgeIo/BlackBoxTest/PciRootBridgeIoBBTestFunction_2.c
index 89adcba91e70..fafbf62f77c6 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PciRootBridgeIo/BlackBoxTest/PciRootBridgeIoBBTestFunction_2.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/PciRootBridgeIo/BlackBoxTest/PciRootBridgeIoBBTestFunction_2.c
@@ -4118,7 +4118,69 @@ AllocateBuffer_Func (
UINTN AttributesNum;
EFI_PCI_ROOT_BRIDGE_IO_DEVICE *RBDev;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
+ EFI_MEMORY_DESCRIPTOR *MemoryMap;
+ EFI_MEMORY_DESCRIPTOR *Entry;
+ UINTN MemoryMapSize;
+ UINTN MapKey;
+ UINTN DescriptorSize;
+ UINT32 DescriptorVersion;
+ UINTN Iterator;
+ BOOLEAN UsableMemoryBelow4G;

+ //
+ // Obtain the memory map size
+ //
+ MemoryMapSize = 0;
+ Status = gBS->GetMemoryMap (
+ &MemoryMapSize,
+ NULL,
+ &MapKey,
+ &DescriptorSize,
+ &DescriptorVersion
+ );
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+ //
+ // Allocating a buffer for the memory map will change
+ // the memory map, so we increase the size here just in case
+ //
+ MemoryMapSize += EFI_PAGE_SIZE;
+ Status = gBS->AllocatePool (
+ EfiLoaderData,
+ MemoryMapSize,
+ (VOID **)&MemoryMap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Get the actual memory map
+ //
+ Status = gBS->GetMemoryMap (
+ &MemoryMapSize,
+ MemoryMap,
+ &MapKey,
+ &DescriptorSize,
+ &DescriptorVersion
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (MemoryMap);
+ }
+
+ //
+ // Check each entry in the memory map for free memory below 4 GiB and set
+ // UsableMemoryBelow4G accordingly
+ //
+ UsableMemoryBelow4G = FALSE;
+ for (Iterator = 0; Iterator < MemoryMapSize; Iterator += DescriptorSize) {
+ Entry = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + Iterator);
+ if ( Entry->PhysicalStart < (EFI_PHYSICAL_ADDRESS)SIZE_4GB
+ && ( Entry->Type == EfiConventionalMemory || Entry->Type == EfiPersistentMemory))
+ {
+ UsableMemoryBelow4G = TRUE;
+ break;
+ }
+ }
+ gBS->FreePool (MemoryMap);

AllocateType = 0;

@@ -4188,7 +4250,14 @@ AllocateBuffer_Func (

for (MemoryTypeNum = 0; MemoryTypeNum < 2; MemoryTypeNum++) {
for (AttributesNum = 0; AttributesNum < 8; AttributesNum++) {
-
+ //
+ // If there is no usable memory below 4 GiB, skip 32-bit allocations
+ //
+ if ( !UsableMemoryBelow4G
+ && !(Attributes[AttributesNum] & EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE))
+ {
+ continue;
+ }
Status = RootBridgeIo->AllocateBuffer (
RootBridgeIo,
AllocateType,
@@ -4298,7 +4367,69 @@ FreeBuffer_Func (
UINTN AttributesNum;
EFI_PCI_ROOT_BRIDGE_IO_DEVICE *RBDev;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
+ EFI_MEMORY_DESCRIPTOR *MemoryMap;
+ EFI_MEMORY_DESCRIPTOR *Entry;
+ UINTN MemoryMapSize;
+ UINTN MapKey;
+ UINTN DescriptorSize;
+ UINT32 DescriptorVersion;
+ UINTN Iterator;
+ BOOLEAN UsableMemoryBelow4G;

+ //
+ // Obtain the memory map size
+ //
+ MemoryMapSize = 0;
+ Status = gBS->GetMemoryMap (
+ &MemoryMapSize,
+ NULL,
+ &MapKey,
+ &DescriptorSize,
+ &DescriptorVersion
+ );
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+ //
+ // Allocating a buffer for the memory map will change
+ // the memory map, so we increase the size here just in case
+ //
+ MemoryMapSize += EFI_PAGE_SIZE;
+ Status = gBS->AllocatePool (
+ EfiLoaderData,
+ MemoryMapSize,
+ (VOID **)&MemoryMap
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Get the actual memory map
+ //
+ Status = gBS->GetMemoryMap (
+ &MemoryMapSize,
+ MemoryMap,
+ &MapKey,
+ &DescriptorSize,
+ &DescriptorVersion
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (MemoryMap);
+ }
+
+ //
+ // Check each entry in the memory map for free memory below 4 GiB and set
+ // UsableMemoryBelow4G accordingly
+ //
+ UsableMemoryBelow4G = FALSE;
+ for (Iterator = 0; Iterator < MemoryMapSize; Iterator += DescriptorSize) {
+ Entry = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + Iterator);
+ if ( Entry->PhysicalStart < (EFI_PHYSICAL_ADDRESS)SIZE_4GB
+ && ( Entry->Type == EfiConventionalMemory || Entry->Type == EfiPersistentMemory))
+ {
+ UsableMemoryBelow4G = TRUE;
+ break;
+ }
+ }
+ gBS->FreePool (MemoryMap);

AllocateType = 0 ;

@@ -4368,7 +4499,14 @@ FreeBuffer_Func (

for (MemoryTypeNum = 0; MemoryTypeNum < 2; MemoryTypeNum++) {
for (AttributesNum = 0; AttributesNum < 8; AttributesNum++) {
-
+ //
+ // If there is no usable memory below 4 GiB, skip 32-bit allocations
+ //
+ if ( !UsableMemoryBelow4G
+ && !(Attributes[AttributesNum] & EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE))
+ {
+ continue;
+ }
Status = RootBridgeIo->AllocateBuffer (
RootBridgeIo,
AllocateType,
--
2.37.3

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


Re: PATCH v1 1/1 MdePkg: Remove Itanium leftover data structure

Michael D Kinney
 

Hi Pawel,

Thank you for the patch. I agree this fixes the size issue.

However, this structure and the associated PPI are defined in the PI Spec
and other modules may depend on the structure layout and would have to be
rebuilt after this structure change.

It would be better to have a backwards compatible change here and I do
not have a specific proposal yet that both reduces the size and
preserves backwards compatibility.

There have been examples in the past where we have had to introduce
a new version of a PPI with a new GUID for this type of change.

I will get back to you on this topic in a few days.

Thanks,

Mike

-----Original Message-----
From: Paweł Poławski <ppolawsk@...>
Sent: Thursday, December 1, 2022 7:36 AM
To: devel@edk2.groups.io
Cc: Kinney, Michael D <michael.d.kinney@...>; Gao, Liming <gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>
Subject: [edk2-devel] PATCH v1 1/1 MdePkg: Remove Itanium leftover data structure

Itanium support has been removed from EDK2 aroun 2019.
ITANIUM_HANDOFF_STATUS data structure looks to be
some leftover from that process.

There is also positive sidefect of this data structure removal.
Due to HOB allocation type used in PEI stage there is a limit
how much data about virtual CPU can be hold. This limit result
in only 1024 vCPU can be used by VM.
With Itanium related data structure removed more allocated space
can be used for vCPU data and with current allocation limit
will change from 1024 to around 8k vCPUs.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>

Signed-off-by: Paweł Poławski <ppolawsk@...>
---
MdePkg/Include/Ppi/SecPlatformInformation.h | 44 --------------------
1 file changed, 44 deletions(-)

diff --git a/MdePkg/Include/Ppi/SecPlatformInformation.h b/MdePkg/Include/Ppi/SecPlatformInformation.h
index 02b0711f189e..fbcd205acd96 100644
--- a/MdePkg/Include/Ppi/SecPlatformInformation.h
+++ b/MdePkg/Include/Ppi/SecPlatformInformation.h
@@ -84,49 +84,6 @@ typedef union {

typedef EFI_HEALTH_FLAGS X64_HANDOFF_STATUS;
typedef EFI_HEALTH_FLAGS IA32_HANDOFF_STATUS;
-///
-/// The hand-off status structure for Itanium architecture.
-///
-typedef struct {
- ///
- /// SALE_ENTRY state : 3 = Recovery_Check
- /// and 0 = RESET or Normal_Boot phase.
- ///
- UINT8 BootPhase;
- ///
- /// Firmware status on entry to SALE.
- ///
- UINT8 FWStatus;
- UINT16 Reserved1;
- UINT32 Reserved2;
- ///
- /// Geographically significant unique processor ID assigned by PAL.
- ///
- UINT16 ProcId;
- UINT16 Reserved3;
- UINT8 IdMask;
- UINT8 EidMask;
- UINT16 Reserved4;
- ///
- /// Address to make PAL calls.
- ///
- UINT64 PalCallAddress;
- ///
- /// If the entry state is RECOVERY_CHECK, this contains the PAL_RESET
- /// return address, and if entry state is RESET, this contains
- /// address for PAL_authentication call.
- ///
- UINT64 PalSpecialAddress;
- ///
- /// GR35 from PALE_EXIT state.
- ///
- UINT64 SelfTestStatus;
- ///
- /// GR37 from PALE_EXIT state.
- ///
- UINT64 SelfTestControl;
- UINT64 MemoryBufferRequired;
-} ITANIUM_HANDOFF_STATUS;

///
/// EFI_SEC_PLATFORM_INFORMATION_RECORD.
@@ -134,7 +91,6 @@ typedef struct {
typedef union {
IA32_HANDOFF_STATUS IA32HealthFlags;
X64_HANDOFF_STATUS x64HealthFlags;
- ITANIUM_HANDOFF_STATUS ItaniumHealthFlags;
} EFI_SEC_PLATFORM_INFORMATION_RECORD;

/**
--
2.38.1


Re: [PATCH v7 2/2] tools_def: add -fno-omit-frame-pointer to GCC48_{IA32,X64}_CC_FLAGS

Brian J. Johnson
 

OK. Doesn't look like a big impact.

Thanks,
Brian J. Johnson

-------- Original Message --------
From: Gerd Hoffmann [mailto:kraxel@...]
Sent: Thursday, December 1, 2022 at 2:38 AM
To: Brian J. Johnson <brian.johnson@...>
Cc: devel@edk2.groups.io, Alexey Kardashevskiy <aik@...>, Liming Gao <gaoliming@...>, Erdem Aktas <erdemaktas@...>, Pawel Polawski <ppolawsk@...>, Jordan Justen <jordan.l.justen@...>, Ard Biesheuvel <ardb+tianocore@...>, Yuwei Chen <yuwei.chen@...>, Tom Lendacky <thomas.lendacky@...>, James Bottomley <jejb@...>, Oliver Steffen <osteffen@...>, Jiewen Yao <jiewen.yao@...>, Min Xu <min.m.xu@...>, Brijesh Singh <brijesh.singh@...>, Bob Feng <bob.c.feng@...>
Subject: [edk2-devel] [PATCH v7 2/2] tools_def: add -fno-omit-frame-pointer to GCC48_{IA32,X64}_CC_FLAGS

On Wed, Nov 30, 2022 at 01:28:42PM -0600, Brian J. Johnson wrote:
Gerd,

Sorry, gotta ask: does this make much difference in the size of the
compiled code? That's a constraint on many real-hardware X64 platforms,
especially for 32-bit code.
Quick test with OvmfPkg/OvmfPkgIa32X64.dsc (sec/pei ia32, dxe x64):

master branch:

FV Space Information
SECFV [11%Full] 212992 (0x34000) total, 23728 (0x5cb0) used, 189264 (0x2e350) free
PEIFV [34%Full] 917504 (0xe0000) total, 319416 (0x4dfb8) used, 598088 (0x92048) free
DXEFV [49%Full] 12582912 (0xc00000) total, 6268032 (0x5fa480) used, 6314880 (0x605b80) free
FVMAIN_COMPACT [98%Full] 1753088 (0x1ac000) total, 1725328 (0x1a5390) used, 27760 (0x6c70) free

with patch applied:

FV Space Information
SECFV [11%Full] 212992 (0x34000) total, 23728 (0x5cb0) used, 189264 (0x2e350) free
PEIFV [34%Full] 917504 (0xe0000) total, 319416 (0x4dfb8) used, 598088 (0x92048) free
DXEFV [50%Full] 12582912 (0xc00000) total, 6335936 (0x60adc0) used, 6246976 (0x5f5240) free
FVMAIN_COMPACT [99%Full] 1753088 (0x1ac000) total, 1738176 (0x1a85c0) used, 14912 (0x3a40) free

So slightly more for 64-bit code.

take care,
Gerd


[PATCH 1/1] RedfishPkg: Fix typos of the .inc filenames

Rebecca Cran <quic_rcran@...>
 

Fix a typo of "RedfishLibs.dsc.inc" in RedfishLibs.dsc.inc, and correct
the name of the .fdf.inc filename in Redfish.fdf.inc.

Signed-off-by: Rebecca Cran <rebecca@...>
---
RedfishPkg/RedfishLibs.dsc.inc | 2 +-
RedfishPkg/Redfish.fdf.inc | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/RedfishPkg/RedfishLibs.dsc.inc b/RedfishPkg/RedfishLibs.dsc.inc
index 50e5dda77357..56950b711f12 100644
--- a/RedfishPkg/RedfishLibs.dsc.inc
+++ b/RedfishPkg/RedfishLibs.dsc.inc
@@ -2,7 +2,7 @@
# Redfish DSC include file for [LibraryClasses*] section of all Architectures.
#
# This file can be included to the [LibraryClasses*] section(s) of a platform DSC file
-# by using "!include RedfishPkg/RedfisLibs.dsc.inc" to specify the library instances
+# by using "!include RedfishPkg/RedfishLibs.dsc.inc" to specify the library instances
# of EDKII network library classes.
#
# (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
diff --git a/RedfishPkg/Redfish.fdf.inc b/RedfishPkg/Redfish.fdf.inc
index 60f31cfcee0c..67e046991424 100644
--- a/RedfishPkg/Redfish.fdf.inc
+++ b/RedfishPkg/Redfish.fdf.inc
@@ -2,7 +2,7 @@
# Redfish FDF include file for [FV*] section of all Architectures.
#
# This file can be included to the [FV*] section(s) of a platform FDF file
-# by using "!include RedfishPkg/RedfisLibs.fdf.inc" to specify the module instances
+# by using "!include RedfishPkg/Redfish.fdf.inc" to specify the module instances
# to be built in the firmware volume.
#
# (C) Copyright 2020-2021 Hewlett Packard Enterprise Development LP<BR>
--
2.30.2


Re: [PATCH 1/3] UsbNetworkPkg/UsbRndis: Add USB RNDIS devices support

Rebecca Cran <quic_rcran@...>
 

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 0000000000..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


PATCH v1 1/1 MdePkg: Remove Itanium leftover data structure

Paweł Poławski
 

Itanium support has been removed from EDK2 aroun 2019.
ITANIUM_HANDOFF_STATUS data structure looks to be
some leftover from that process.

There is also positive sidefect of this data structure removal.
Due to HOB allocation type used in PEI stage there is a limit
how much data about virtual CPU can be hold. This limit result
in only 1024 vCPU can be used by VM.
With Itanium related data structure removed more allocated space
can be used for vCPU data and with current allocation limit
will change from 1024 to around 8k vCPUs.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>

Signed-off-by: Paweł Poławski <ppolawsk@...>
---
MdePkg/Include/Ppi/SecPlatformInformation.h | 44 --------------------
1 file changed, 44 deletions(-)

diff --git a/MdePkg/Include/Ppi/SecPlatformInformation.h b/MdePkg/Include/Ppi/SecPlatformInformation.h
index 02b0711f189e..fbcd205acd96 100644
--- a/MdePkg/Include/Ppi/SecPlatformInformation.h
+++ b/MdePkg/Include/Ppi/SecPlatformInformation.h
@@ -84,49 +84,6 @@ typedef union {

typedef EFI_HEALTH_FLAGS X64_HANDOFF_STATUS;
typedef EFI_HEALTH_FLAGS IA32_HANDOFF_STATUS;
-///
-/// The hand-off status structure for Itanium architecture.
-///
-typedef struct {
- ///
- /// SALE_ENTRY state : 3 = Recovery_Check
- /// and 0 = RESET or Normal_Boot phase.
- ///
- UINT8 BootPhase;
- ///
- /// Firmware status on entry to SALE.
- ///
- UINT8 FWStatus;
- UINT16 Reserved1;
- UINT32 Reserved2;
- ///
- /// Geographically significant unique processor ID assigned by PAL.
- ///
- UINT16 ProcId;
- UINT16 Reserved3;
- UINT8 IdMask;
- UINT8 EidMask;
- UINT16 Reserved4;
- ///
- /// Address to make PAL calls.
- ///
- UINT64 PalCallAddress;
- ///
- /// If the entry state is RECOVERY_CHECK, this contains the PAL_RESET
- /// return address, and if entry state is RESET, this contains
- /// address for PAL_authentication call.
- ///
- UINT64 PalSpecialAddress;
- ///
- /// GR35 from PALE_EXIT state.
- ///
- UINT64 SelfTestStatus;
- ///
- /// GR37 from PALE_EXIT state.
- ///
- UINT64 SelfTestControl;
- UINT64 MemoryBufferRequired;
-} ITANIUM_HANDOFF_STATUS;

///
/// EFI_SEC_PLATFORM_INFORMATION_RECORD.
@@ -134,7 +91,6 @@ typedef struct {
typedef union {
IA32_HANDOFF_STATUS IA32HealthFlags;
X64_HANDOFF_STATUS x64HealthFlags;
- ITANIUM_HANDOFF_STATUS ItaniumHealthFlags;
} EFI_SEC_PLATFORM_INFORMATION_RECORD;

/**
--
2.38.1


PATCH v1 0/1 Remove deprecated Itanium data

Paweł Poławski
 

Due to allocation type used in HOB responsible for vCPU data allocation
EDK2 is limited to only 1024 vCPU when running with Qemu.
After some research and feedback from edk-devel mailing list it looks
like solution for this may be quie easy. Instead of changing allocation
type we can save the data by removing some deprecated things.

Itanium support has been removed from EDK2 aroun 2019.
ITANIUM_HANDOFF_STATUS data structure looks to be
some leftover from that process.

Saved space will result in increase of vCPU limit to around 8k,
without changing allocation type (64k blocks).

I checked the code and it looks like this data structure is not used
anywhere else apart of this header.

Paweł Poławski (1):
MdePkg: Remove Itanium leftover data structure

MdePkg/Include/Ppi/SecPlatformInformation.h | 44 --------------------
1 file changed, 44 deletions(-)

--
2.38.1


Re: [PATCH V3] MdeModulePkg/RegularExpressionDxe: Fix GCC build error

Michael D Kinney
 

Reviewed-by: Michael D Kinney <michael.d.kinney@...>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Nickle Wang via groups.io
Sent: Thursday, December 1, 2022 4:42 AM
To: devel@edk2.groups.io
Cc: Wang, Jian J <jian.j.wang@...>; Gao, Liming <gaoliming@...>; Kinney, Michael D
<michael.d.kinney@...>; Nick Ramirez <nramirez@...>
Subject: [edk2-devel] [PATCH V3] MdeModulePkg/RegularExpressionDxe: Fix GCC build error

Fix GCC build error on AARCH64 system.

Signed-off-by: Nickle Wang <nicklew@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Liming Gao <gaoliming@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Nick Ramirez <nramirez@...>
---
.../Universal/RegularExpressionDxe/OnigurumaUefiPort.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h
b/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h
index 3dc207da3e..248109b0c9 100644
--- a/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h
+++ b/MdeModulePkg/Universal/RegularExpressionDxe/OnigurumaUefiPort.h
@@ -4,6 +4,7 @@

(C) Copyright 2014-2021 Hewlett Packard Enterprise Development LP<BR>
Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -36,11 +37,9 @@ typedef INTN intptr_t;
#define offsetof OFFSET_OF
#endif

-#ifdef MDE_CPU_IA32
+#if defined (MDE_CPU_IA32) || defined (MDE_CPU_ARM) || defined (MDE_CPU_EBC)
#define SIZEOF_VOIDP 4
-#endif
-
-#ifdef MDE_CPU_X64
+#else
#define SIZEOF_VOIDP 8
#endif

--
2.38.1.windows.1





Re: [edk2-test][PATCH v1 1/1] uefi-sct/SctPkg: Check for memory below 4G

G Edhaya Chandran
 

Reviewed-by: G Edhaya Chandran <edhaya.chandran@...>

Refactoring suggestion: Can the code for checking of the UsableMemoryBelow4G moved to a function? Since it is used in two places.


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

Lendacky, Thomas
 

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 <aik@...>
---
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 = 0xffff0000,
The PCD for this is 64-bits, should this be 0xffffffffffff0000?

Thanks,
Tom

+ CCAttrAmdSevFeatureDebugSwap = 0x00010000,
/* The guest is running with Intel TDX memory encryption enabled. */
CCAttrIntelTdx = 0x200,
} CONFIDENTIAL_COMPUTING_GUEST_ATTR;
#define CC_GUEST_IS_TDX(x) ((x) == CCAttrIntelTdx)
-#define CC_GUEST_IS_SEV(x) ((x) == CCAttrAmdSev || (x) == CCAttrAmdSevEs || (x) == CCAttrAmdSevSnp)
+#define _CC_GUEST_IS_SEV(x) ((x) == CCAttrAmdSev || (x) == CCAttrAmdSevEs || (x) == CCAttrAmdSevSnp)
+#define CC_GUEST_IS_SEV(x) _CC_GUEST_IS_SEV((x) & ~CCAttrAmdSevFeatureMask)
#endif