]> git.proxmox.com Git - mirror_edk2.git/log
mirror_edk2.git
15 months agoOvmfPkg: raise DXEFV size to 13 MB in the traditional platform FDFs
Laszlo Ersek [Tue, 3 Jan 2023 15:02:42 +0000 (16:02 +0100)]
OvmfPkg: raise DXEFV size to 13 MB in the traditional platform FDFs

Similarly to the "cadence" mentioned in commit d272449d9e1e ("OvmfPkg:
raise DXEFV size to 11 MB", 2018-05-29), it's been ~1.75 years since
commit 5e75c4d1fe4f ("OvmfPkg: raise DXEFV size to 12 MB", 2020-03-11),
and we've outgrown DXEFV again (with NOOPT builds).  Increase the DXEFV
size to 13MB now.

Do not modify all platform FDF files under OvmfPkg.  "BhyveX64.fdf" is
still at 11MB, "OvmfXen.fdf" at 10MB.  The "AmdSevX64.fdf",
"CloudHvX64.fdf", "IntelTdxX64.fdf" and "MicrovmX64.fdf" flash devices
could be modified similarly (from 12MB to 13MB), but I don't use or build
those platforms.

Tested on:
- IA32, q35, SMM_REQUIRE, Fedora 30 guest
- X64, pc (i440fx), no SMM, RHEL-7.9 guest
- IA32X64, q35, SMM_REQUIRE, RHEL-7.9 guest

Test steps:
- configure 3 VCPUs
- boot
- run "taskset -c $I efibootmgr" with $I covering 0..2
- systemctl suspend
- resume from virt-manager
- run "taskset -c $I efibootmgr" with $I covering 0..2

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Sebastien Boeuf <sebastien.boeuf@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4236
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoOvmfPkg/QemuVideoDxe/VbeShim.sh: remove end-of-options delimiter for nasm
Laszlo Ersek [Tue, 3 Jan 2023 15:02:41 +0000 (16:02 +0100)]
OvmfPkg/QemuVideoDxe/VbeShim.sh: remove end-of-options delimiter for nasm

Per my bisection: nasm broke the parsing of the "--" end-of-options
delimiter in commit 55568c1193df ("nasm: scan the command line twice",
2016-10-03), part of the nasm-2.13 release. The parsing remains broken in
at least nasm-2.15.03. The (invalid) error message is: "more than one
input file specified". I've filed the following ticket for upstream nasm
(and ndisasm): <https://bugzilla.nasm.us/show_bug.cgi?id=3392829>.

Since the delimiter is not necessary in practice (due to $STEM being
"VbeShim", i.e., not starting with a hyphen), simply remove the delimiter.

Tested by enabling DEBUG in "VbeShim.asm", running the script, building
OVMF, booting Windows 7, and checking the firmware log (debug console).

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3876
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
15 months agoMdeModulePkg/Bus/Pci/XhciDxe: Reset port if status change returns an error
Sean Rhodes [Fri, 16 Dec 2022 12:24:18 +0000 (12:24 +0000)]
MdeModulePkg/Bus/Pci/XhciDxe: Reset port if status change returns an error

Force resetting the port by clearing the USB_PORT_STAT_C_RESET bit in
PortChangeStatus when XhcPollPortStatusChange fails

Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
15 months ago.azurepipelines: Install code coverage tool
Gua Guo [Tue, 8 Nov 2022 08:38:49 +0000 (16:38 +0800)]
.azurepipelines: Install code coverage tool

For Windows add below tool for code coverage
1. OpenCppCoverage: parsing pdb file to generate coverage
data
2. pycobertura: show up html format data for coverage data

For Linux add below tool for code coverage
1. lcov: parsing gcda gcno file to generate coverage data
2. lcov-cobertura: convert coverage data to cobertura format
3. pycobertura: show up html format data for coverage data

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
15 months agoBaseTools/Plugin: Add coverage support for Unit Test
Gua Guo [Tue, 27 Sep 2022 04:25:17 +0000 (12:25 +0800)]
BaseTools/Plugin: Add coverage support for Unit Test

For GCC, use lcov to generate Unit Test code coverage
report

For VS2019, use OpenCppCoverage to generate code
coverage report

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Liming Gao <gaoliming@bysoft.com.cn>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Michael Kubacki <mikuback@linux.microsoft.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
15 months agoUnitTestFrameworkPkg: Add code coverage support for GCC
Gua Guo [Tue, 27 Sep 2022 04:24:18 +0000 (12:24 +0800)]
UnitTestFrameworkPkg: Add code coverage support for GCC

In order to collect code coverage after running executable
file, generate *.gcda and *.gcno file that require by lcov tool
to generate code coverage report.

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Reviewed-by: Michael Kubacki <mikuback@linux.microsoft.com>
Signed-off-by: Gua Guo <gua.guo@intel.com>
15 months agoUefiCpuPkg/PiSmmCpuDxeSmm:Fix PF issue caused by smm page table code
Tan, Dun [Tue, 3 Jan 2023 05:56:17 +0000 (13:56 +0800)]
UefiCpuPkg/PiSmmCpuDxeSmm:Fix PF issue caused by smm page table code

When setting new page table pool to RO, only disable/enable WP when
Cr0.WP has been set to 1 to fix potential PF caused by b822be1a20
(UefiCpuPkg/PiSmmCpuDxeSmm: Introduce page table pool mechanism).
With previous code, if someone want to modify the page table and
Cr0.WP has been cleared before modify page table, Cr0.WP may be set
to 1 again since new pool may be generated during this process
Then PF fault may happens.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
15 months agoBaseTools: Generate deps for Arm targets
Jake Garver via groups.io [Thu, 8 Dec 2022 16:22:11 +0000 (00:22 +0800)]
BaseTools: Generate deps for Arm targets

Prior to this change, deps were not generated for Arm and AARCH64
libraries when MODULE_TYPE was BASE, SEC, PEI_CORE, or PIEM. That
resulted in bad incremental builds.

Signed-off-by: Jake Garver <jake@nvidia.com>
Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
15 months agoBaseTools: Use BUILD_CC when checking gcc version in DevicePath
Jake Garver [Tue, 20 Dec 2022 13:14:12 +0000 (21:14 +0800)]
BaseTools: Use BUILD_CC when checking gcc version in DevicePath

When checking the version in DevicePath's Makefile, use BUILD_CC instead
of assuming "gcc".  BUILD_CC is set in header.makefile and is the
compiler that will actually be used to build DevicePath.  It defaults to
"gcc", but may be overridden.

Signed-off-by: Jake Garver <jake@nvidia.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
15 months agoBaseTools: Fix IA32 UINT64 alignment for CLANG toolchains
Pedro Falcato [Fri, 16 Dec 2022 19:50:20 +0000 (03:50 +0800)]
BaseTools: Fix IA32 UINT64 alignment for CLANG toolchains

Currently, UINT64 is not 8-byte aligned for CLANG* toolchains on IA32,
which causes ABI differences between IA32 and X64 in such simple examples as:

struct S {UINT32 A; UINT64 B;};

Pass -malign-double to align it to 8 bytes, as is done for GCC already.

Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
Cc: Marvin H?user <mhaeuser@posteo.de>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
16 months agoOvmfPkg: Use NestedInterruptTplLib in nested interrupt handlers
Michael Brown [Fri, 9 Dec 2022 10:20:27 +0000 (10:20 +0000)]
OvmfPkg: Use NestedInterruptTplLib in nested interrupt handlers

Prevent stack underrun in the event of a timer interrupt storm in
LocalApicTimerDxe and 8254TimerDxe interrupt handlers by using the
helper functions provided by NestedInterruptTplLib.

This fixes the same problem as addressed in commit 239b50a86
("OvmfPkg: End timer interrupt later to avoid stack overflow under
load"), but does so without breaking nested timer interrupts.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2815
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4162
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
16 months agoOvmfPkg: Add library to handle TPL from within nested interrupt handlers
Michael Brown [Fri, 9 Dec 2022 10:20:24 +0000 (10:20 +0000)]
OvmfPkg: Add library to handle TPL from within nested interrupt handlers

UEFI requires us to support nested interrupts, but provides no way for
an interrupt handler to call RestoreTPL() without implicitly
re-enabling interrupts.  In a virtual machine, it is possible for a
large burst of interrupts to arrive.  We must prevent such a burst
from leading to stack underrun, while continuing to allow nested
interrupts to occur.

This can be achieved by allowing, when provably safe to do so, an
inner interrupt handler to return from the interrupt without restoring
the TPL and with interrupts remaining disabled after IRET, with the
deferred call to RestoreTPL() then being issued from the outer
interrupt handler.  This is necessarily messy and involves direct
manipulation of the interrupt stack frame, and so should not be
implemented as open-coded logic within each interrupt handler.

Add the Nested Interrupt TPL Library (NestedInterruptTplLib) to
provide helper functions that can be used by nested interrupt handlers
in place of RaiseTPL()/RestoreTPL().

Example call tree for a timer interrupt occurring at TPL_APPLICATION
with a nested timer interrupt that makes its own call to RestoreTPL():

  outer TimerInterruptHandler()
    InterruptedTPL == TPL_APPLICATION
    ...
    IsrState->InProgressRestoreTPL = TPL_APPLICATION;
    gBS->RestoreTPL (TPL_APPLICATION);
      EnableInterrupts();
      dispatch a TPL_CALLBACK event
        gEfiCurrentTpl = TPL_CALLBACK;
        nested timer interrupt occurs
        inner TimerInterruptHandler()
          InterruptedTPL == TPL_CALLBACK
          ...
          IsrState->InProgressRestoreTPL = TPL_CALLBACK;
          gBS->RestoreTPL (TPL_CALLBACK);
            EnableInterrupts();
          DisableInterrupts();
          IsrState->InProgressRestoreTPL = TPL_APPLICATION;
          IRET re-enables interrupts
      ... finish dispatching TPL_CALLBACK events ...
      gEfiCurrentTpl = TPL_APPLICATION;
    DisableInterrupts();
    IsrState->InProgressRestoreTPL = 0;
    sees IsrState->DeferredRestoreTPL == FALSE and returns
    IRET re-enables interrupts

Example call tree for a timer interrupt occurring at TPL_APPLICATION
with a nested timer interrupt that defers its call to RestoreTPL() to
the outer instance of the interrupt handler:

  outer TimerInterruptHandler()
    InterruptedTPL == TPL_APPLICATION
    ...
    IsrState->InProgressRestoreTPL = TPL_APPLICATION;
    gBS->RestoreTPL (TPL_APPLICATION);
      EnableInterrupts();
      dispatch a TPL_CALLBACK event
      ... finish dispatching TPL_CALLBACK events ...
      gEfiCurrentTpl = TPL_APPLICATION;
      nested timer interrupt occurs
      inner TimerInterruptHandler()
        InterruptedTPL == TPL_APPLICATION;
        ...
        sees InterruptedTPL == IsrState->InProgressRestoreTPL
        IsrState->DeferredRestoreTPL = TRUE;
        DisableInterruptsOnIret();
        IRET returns without re-enabling interrupts
    DisableInterrupts();
    IsrState->InProgressRestoreTPL = 0;
    sees IsrState->DeferredRestoreTPL == TRUE and loops
    IsrState->InProgressRestoreTPL = TPL_APPLICATION;
    gBS->RestoreTPL (TPL_APPLICATION);  <-- deferred call
      EnableInterrupts();
    DisableInterrupts();
    IsrState->InProgressRestoreTPL = 0;
    sees IsrState->DeferredRestoreTPL == FALSE and returns
    IRET re-enables interrupts

Cc: Paolo Bonzini <pbonzini@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4162
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
16 months agoOvmfPkg: Send EOI before RestoreTPL() in timer interrupt handlers
Michael Brown [Fri, 9 Dec 2022 10:20:21 +0000 (10:20 +0000)]
OvmfPkg: Send EOI before RestoreTPL() in timer interrupt handlers

Deferring the EOI until after the call to RestoreTPL() means that any
callbacks invoked by RestoreTPL() will run with timer interrupt
delivery disabled.  If any such callbacks themselves rely on timers to
implement timeout loops, then the callbacks will get stuck in an
infinite loop from which the system will never recover.

This reverts commit 239b50a86 ("OvmfPkg: End timer interrupt later to
avoid stack overflow under load").

Cc: Paolo Bonzini <pbonzini@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=4162
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
16 months agoOvmfPkg/PlatformInitLib: pass through reservations from qemu
Gerd Hoffmann [Wed, 7 Dec 2022 05:32:15 +0000 (06:32 +0100)]
OvmfPkg/PlatformInitLib: pass through reservations from qemu

qemu uses the etc/e820 fw_cfg file not only for memory, but
also for reservations.  Handle reservations by adding resource
descriptor hobs for them.

A typical qemu configuration has a small reservation between
lapic and flash:

  # sudo cat /proc/iomem
  [ ... ]
  fee00000-fee00fff : Local APIC
  feffc000-feffffff : Reserved          <= HERE
  ffc00000-ffffffff : Reserved
  [ ... ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
16 months agoOvmfPkg: fix PlatformConfig
Gerd Hoffmann [Fri, 9 Dec 2022 11:22:44 +0000 (12:22 +0100)]
OvmfPkg: fix PlatformConfig

The Hii form is named "MainFormState" and the EFI variable is named
"PlatformConfig".  Take into account the different names.

Fixes: aefcc91805fd ("OvmfPkg/PlatformDxe: Handle all requests in ExtractConfig and RouteConfig")
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
16 months agoUefiPayloadPkg: Fix boot issue for non-universal payload
Guo Dong [Wed, 21 Dec 2022 18:36:37 +0000 (11:36 -0700)]
UefiPayloadPkg: Fix boot issue for non-universal payload

BDS module was moved from DXEFV to newly created BDSFV recently.
Non-universal UEFI payload doesn't support multiple FV, so it failed
to boot since BDS module could not be found.
This patch add BDS back to DXEFV when UNIVERSAL_PAYLOAD is not set.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: Guo Dong <guo.dong@intel.com>
Reviewed-by: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
16 months agoArmVirtPkg: Remove CcProbeLib from ArmVirtQemu.dsc
Min M Xu [Thu, 22 Dec 2022 13:11:56 +0000 (21:11 +0800)]
ArmVirtPkg: Remove CcProbeLib from ArmVirtQemu.dsc

Since CcProbeLib is not used in AcpiPlatformDxe, CcProbeLib can be removed
from ArmVirtQemu.dsc.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
16 months agoOvmfPkg/AcpiPlatformDxe: Check PcdConfidentialComputingGuestAttr
Min M Xu [Thu, 22 Dec 2022 13:11:55 +0000 (21:11 +0800)]
OvmfPkg/AcpiPlatformDxe: Check PcdConfidentialComputingGuestAttr

PcdConfidentialComputingGuestAttr can be used to check the cc guest
type, including td-guest or sev-guest. CcProbe() can do the same
thing but CcProbeLib should be included in the dsc which uses
AcpiPlatformDxe. The difference between PcdConfidentialComputingGuestAttr
and CcProbe() is that PcdConfidentialComputingGuestAttr cannot be used
in multi-processor scenario but CcProbe() can. But there is no such
issue in AcpiPlatformDxe.

So we use PcdConfidentialComputingGuestAttr instead of CcProbeLib so that
it is simpler.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
16 months agoPcAtChipsetPkg: Move RTC PCD to dynamic PCD
KasimX Liu [Wed, 14 Dec 2022 07:56:23 +0000 (15:56 +0800)]
PcAtChipsetPkg: Move RTC PCD to dynamic PCD

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

In order to remove RTC_INDEX/RTC_TARGET from
the UplBuild macro list,change the RTC_INDEX
/RTC_TARGET type from PcdsFixedAtBuild to PcdsDynamicEx

Cc: Guo Dong <guo.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: KasimX Liu <kasimx.liu@intel.com>
16 months agotools_def: add -fno-omit-frame-pointer to GCC48_{IA32,X64}_CC_FLAGS
Gerd Hoffmann [Wed, 30 Nov 2022 09:44:14 +0000 (17:44 +0800)]
tools_def: add -fno-omit-frame-pointer to GCC48_{IA32,X64}_CC_FLAGS

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 <kraxel@redhat.com>
Tested-by: Liming Gao <gaoliming@byosoft.com.cn>
16 months agotools_def: remove GCC_IA32_CC_FLAGS/GCC_X64_CC_FLAGS
Gerd Hoffmann [Wed, 30 Nov 2022 09:44:13 +0000 (17:44 +0800)]
tools_def: remove GCC_IA32_CC_FLAGS/GCC_X64_CC_FLAGS

They are not used anywhere.  Remove them.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
16 months agoCryptoPkg: Need to enable crypto functions
Judah Vang [Wed, 21 Dec 2022 03:04:18 +0000 (11:04 +0800)]
CryptoPkg: Need to enable crypto functions

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

V2: Update Readme and CryptoPkg.dsc to reflect changes and be in sync.

V1: Enable CryptAes for PEI phase. Enable CryptHkdf for SMM phase.
    Update Readme.md

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Nishant C Mistry <nishant.c.mistry@intel.com>
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Nishant C Mistry <nishant.c.mistry@intel.com>
Signed-off-by: Judah Vang <judah.vang@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoUefiCpuPkg: Simplify the code to set smm page table as RO
Tan, Dun [Wed, 21 Dec 2022 04:21:56 +0000 (12:21 +0800)]
UefiCpuPkg: Simplify the code to set smm page table as RO

Simplify the code to set memory used by smm page table as RO.
Since memory used by smm page table are in PageTablePool list,
we only need to set all PageTablePool as ReadOnly in smm page
table itself. Also, we only need to flush tlb once after
setting all page table pool as Read Only.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
16 months agoUefiCpuPkg: Remove unused API in SmmCpuFeaturesLib.h
Tan, Dun [Wed, 21 Dec 2022 04:21:55 +0000 (12:21 +0800)]
UefiCpuPkg: Remove unused API in SmmCpuFeaturesLib.h

Remove SmmCpuFeaturesAllocatePageTableMemory in this headfile.
This API is not used by PiSmmCpuDxeSmm driver any more. Also
no other files use this API.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
16 months agoUefiCpuPkg/PiSmmCpuDxeSmm: Introduce page table pool mechanism
duntan [Wed, 21 Dec 2022 04:21:54 +0000 (12:21 +0800)]
UefiCpuPkg/PiSmmCpuDxeSmm: Introduce page table pool mechanism

Introduce page table pool mechanism for smm page table to simplify
page table memory management and protection. This mechanism has been
used in DxeIpl. The basic idea is to allocate a bunch of continuous
pages of memory in advance, and all future page tables consumption
will happen in those pool instead of system memory.
Since we have centralized page tables, we only need to mark all page
table pools as RO, instead of searching page table memory layer by
layer in smm page table. Once current page table pool has been used
up, another memory pool will be allocated and the new pool will also
be set as RO if current page table memory has been marked as RO.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
16 months agoOvmfPkg/OvmfXen: Build platform info HOB in XenPlatformPei
Anthony PERARD [Mon, 19 Dec 2022 16:36:20 +0000 (00:36 +0800)]
OvmfPkg/OvmfXen: Build platform info HOB in XenPlatformPei

Copy the function BuildPlatformInfoHob() from OvmfPkg/PlatformPei.

QemuFwCfgLib expect this HOB to be present, or fails to do anything.
InternalQemuFwCfgIsAvailable() from QemuFwCfgPeiLib module will not
check if the HOB is actually present for example and try to use a NULL
pointer.

Fixes: cda98df16228 ("OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + mQemuFwCfgDmaSupported")
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/PlatformInitLib: Implement multi-core accept memory for TDVF
Min M Xu [Tue, 20 Dec 2022 08:42:40 +0000 (16:42 +0800)]
OvmfPkg/PlatformInitLib: Implement multi-core accept memory for TDVF

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

TDVF once accepts memory only by BSP. To improve the boot performance
this patch introduce the multi-core accpet memory. Multi-core means
BSP and APs work together to accept memory.

TDVF leverages mailbox to wake up APs. It is not enabled in MpInitLib
(Which requires SIPI). So multi-core accept memory cannot leverages
MpInitLib to coordinate BSP and APs to work together.

So TDVF split the accept memory into 2 phases.
- AcceptMemoryForAPsStack:
  BSP accepts a small piece of memory which is then used by APs to setup
  stack. We assign a 16KB stack for each AP. So a td-guest with 256 vCPU
  requires 255*16KB = 4080KB.
- AcceptMemory:
  After above small piece of memory is accepted, BSP commands APs to
  accept memory by sending AcceptPages command in td-mailbox. Together
  with the command and accpet-function, the APsStack address is send
  as well. APs then set the stack and jump to accept-function to accept
  memory.

AcceptMemoryForAPsStack accepts as small memory as possible and then jump
to AcceptMemory. It fully takes advantage of BSP/APs to work together.
After accept memory is done, the memory region for APsStack is not used
anymore. It can be used as other private memory. Because accept-memory
is in the very beginning of boot process and it will not impact other
phases.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg: Enable APs to accept memory for TDVF
Min M Xu [Tue, 20 Dec 2022 08:42:39 +0000 (16:42 +0800)]
OvmfPkg: Enable APs to accept memory for TDVF

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

TDVF APs once did nothing but spin around to wait for the Wakeup command.
This patch enables APs to handle the AcceptPages command. Once APs find
the AcceptPages command, it set its stack and jump to the function of
ApAcceptMemoryResourceRange (which will be introduced in the following
patch).

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/Sec: Move TDX APs related nasm code to IntelTdxAPs.nasm
Min M Xu [Tue, 20 Dec 2022 08:42:38 +0000 (16:42 +0800)]
OvmfPkg/Sec: Move TDX APs related nasm code to IntelTdxAPs.nasm

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

This patch moves the TDX APs nasm code from SecEntry.nasm to
IntelTdxAPs.nasm. IntelTdxX64 and OvmfPkgX64 use the same nasm so that
it can be easier to be managed. In the following patch there will be
AcceptMemory related changes in IntelTdxAPs.nasm.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg: Add TdxMailboxLibNull in some platform dsc
Min M Xu [Tue, 20 Dec 2022 08:42:37 +0000 (16:42 +0800)]
OvmfPkg: Add TdxMailboxLibNull in some platform dsc

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

In the following patches TdxMailboxLib will be included in
PlatformInitLib. While PlatformInitLib is imported by some IA32/X64
platforms (for example AmdSevX64.dsc). So TdxMailboxLibNull is added in
those platforms which don't support TDX feature.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/TdxMailboxLib: Add NULL instance of TdxMailboxLib
Min M Xu [Tue, 20 Dec 2022 08:42:36 +0000 (16:42 +0800)]
OvmfPkg/TdxMailboxLib: Add NULL instance of TdxMailboxLib

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

TdxMailboxLib is designed only for TDX guest which arch is X64. This
patch set the VALID_ARCHITECTURES of TdxMailboxLib as X64.

Because in the following patches TdxMailboxLib will be included in
PlatformInitLib. While PlatformInitLib is imported by some X64 platforms
(for example AmdSevX64.dsc). So we need a NULL instance of TdxMailboxLib
which VALID_ARCHITECTURES is X64 as well. Based on this consideration
we design TdxMailboxLibNull.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/TdxMailboxLib: Delete global variables
Min M Xu [Tue, 20 Dec 2022 08:42:35 +0000 (16:42 +0800)]
OvmfPkg/TdxMailboxLib: Delete global variables

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

TdxMailboxLib once was designed to be used in DXE phase. But now it is
going to be used in SEC/PEI phase (in the following patches). Global
variables are not allowed. The library is refactored after those global
variables are deleted.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoSecurityPkg: deprecate RpmcLib and VariableKeyLib
Jian J Wang [Thu, 15 Dec 2022 03:02:23 +0000 (11:02 +0800)]
SecurityPkg: deprecate RpmcLib and VariableKeyLib

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

There's no real usage of these two libraries. They're deprecated.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Nishant C Mistry <nishant.c.mistry@intel.com>
Cc: Judah Vang <judah.vang@intel.com>
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Acked-by: Michael D Kinney <michael.d.kinney@intel.com>
16 months agoUefiPayloadPkg: Fixed that The UPL info section is not aligned at 4-byte
MarsX Lin [Tue, 20 Dec 2022 09:03:35 +0000 (17:03 +0800)]
UefiPayloadPkg: Fixed that The UPL info section is not aligned at 4-byte

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

Align .upld_info with 4-byte boundary by spec

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: MarsX Lin <marsx.lin@intel.com>
16 months agoMdePkg: Fix typos and spacing in Library/PerformanceLib.h
Rebecca Cran [Tue, 29 Nov 2022 12:22:55 +0000 (20:22 +0800)]
MdePkg: Fix typos and spacing in Library/PerformanceLib.h

- Fix typos of "disable".
- Fix typos of "performance".
- Fix missing spaces.
- Use comma instead of period when the sentence continues on the next
  line.
- Fix typo of "PERF_CORE_LOAD_IMAGE".

Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
16 months agoMdePkg: Fix typo of EFI_INVALID_PARAMETER in Protocol/UsbIo.h
Rebecca Cran [Tue, 29 Nov 2022 12:27:26 +0000 (20:27 +0800)]
MdePkg: Fix typo of EFI_INVALID_PARAMETER in Protocol/UsbIo.h

Fix typo of EFI_INVALID_PARAMETER in Protocol/UsbIo.h by adding a
missing 'R'.

Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
16 months agoMdeModulePkg/Bus/Pci/XhciDxe: Check port is compatible before getting PSIV
Sean Rhodes [Fri, 16 Dec 2022 08:58:06 +0000 (16:58 +0800)]
MdeModulePkg/Bus/Pci/XhciDxe: Check port is compatible before getting PSIV

On some platforms, including Sky Lake and Kaby Lake, the PSIV (Protocol
Speed ID Value) indices are 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 Compatible Port Offset to find
the starting Port of Root Hubs that support the protocol.

Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
16 months agoMdeModulePkg/XhciDxe/Xhci: Don't check for invalid PSIV
Matt DeVillier [Fri, 16 Dec 2022 08:58:05 +0000 (16:58 +0800)]
MdeModulePkg/XhciDxe/Xhci: Don't check for invalid PSIV

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@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-by: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
16 months agoUefiPayloadPkg: Add CpuPageTableLib required by MpInitLib.
Yuanhao Xie [Mon, 19 Dec 2022 21:40:17 +0000 (05:40 +0800)]
UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib.

Add CpuPageTableLib required by MpInitLib in UefiPayloadPkg.

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
16 months agoOvmfPkg: Add CpuPageTableLib required by MpInitLib.
Yuanhao Xie [Mon, 19 Dec 2022 21:40:16 +0000 (05:40 +0800)]
OvmfPkg: Add CpuPageTableLib required by MpInitLib.

Add CpuPageTableLib required by MpInitLib in OvmfPkg.

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Acked-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoUefiCpuPkg: Has APs in 64 bit long-mode before booting to OS.
Xie, Yuanhao [Mon, 19 Dec 2022 21:40:15 +0000 (05:40 +0800)]
UefiCpuPkg: Has APs in 64 bit long-mode before booting to OS.

During the finalization of Mp initialization before booting into the OS,
 depending on whether Mwait is supported or not, AsmRelocateApLoop
 places Aps in MWAIT-loop or HLT-loop.

Since paging is necessary for long mode, the original implementation of
moving APs to 32-bit was to disable paging to ensure that the booting
does not crash.

The current modification creates a page table in reserved memory,
avoiding switching modes and reclaiming memory by OS. This modification
is only for 64 bit mode.

More specifically, we keep the AMD logic as the original code flow,
extract and update the Intel-related code, where the APs would stay
in 64-bit, and run in a Mwait or Hlt loop until the OS wake them up.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
16 months agoUefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd
Yuanhao Xie [Mon, 19 Dec 2022 21:40:14 +0000 (05:40 +0800)]
UefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd

AsmRelocateApLoop is replicated for future Intel Logic Extraction,
further brings AP into 64-bit, and enables paging.

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
16 months agoUefiPayloadPkg/SerialPortLib: Enhance multi port behaviour
Kavya [Tue, 20 Dec 2022 03:56:59 +0000 (09:26 +0530)]
UefiPayloadPkg/SerialPortLib: Enhance multi port behaviour

Add condition to return success if mUartCount is greater
than zero in SerialPortInitialize() to avoid filling mUartInfo
with the same hob data when SerialPortInitialize() is called
multiple times. Also add proper conditions in SerialPortRead
function to read the data properly from multiple UART's.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: Kavya <k.kavyax.sravanthi@intel.com>
16 months agoEmulatorPkg/RedfishHostInterface: Add NULL function
Abner Chang [Mon, 19 Dec 2022 13:18:20 +0000 (21:18 +0800)]
EmulatorPkg/RedfishHostInterface: Add NULL function

Add NULL function
RedfishPlatformHostInterfaceNotification that returns
EFI_UNSUPPORTED.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
16 months agoRedfishPkg/RedfishHostInterface: Platform Redfish HI notification
Abner Chang [Mon, 19 Dec 2022 13:18:00 +0000 (21:18 +0800)]
RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

For some use cases, Redfish host interface table relies on
the certain EFI protocols installation at the driver connection.
Redfish host interface DXE driver is not able to build the
SMBIOS type 42h record at driver entry point. This patch adds
the mechanism in Redfish host interface DXE driver to listen
to EFI protocol installed by platform library that indicates
the necessary information is ready for building SMBIOS 42h
record.

Signed-off-by: Abner Chang <abner.chang@amd.com>
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Reviewed-by: Nickle Wang <nicklew@nvidia.com>
16 months agoOvmfPkg/PlatformInitLib: Fix integrity checking failed of NvVarStore
Chun-Yi Lee [Thu, 15 Dec 2022 14:27:23 +0000 (22:27 +0800)]
OvmfPkg/PlatformInitLib: Fix integrity checking failed of NvVarStore

In the commit 4f173db8b4 "OvmfPkg/PlatformInitLib: Add functions for
EmuVariableNvStore", it introduced a PlatformValidateNvVarStore() function
for checking the integrity of NvVarStore.

In some cases when the VariableHeader->StartId is VARIABLE_DATA, the
VariableHeader->State is not just one of the four primary states:
VAR_IN_DELETED_TRANSITION, VAR_DELETED, VAR_HEADER_VALID_ONLY, VAR_ADDED.
The state may combined two or three states, e.g.

    0x3C = (VAR_IN_DELETED_TRANSITION & VAR_ADDED) & VAR_DELETED
or
    0x3D = VAR_ADDED & VAR_DELETED

When the variable store has those variables, system booting/rebooting will
hangs in a ASSERT:

NvVarStore Variable header State was invalid.
ASSERT
/mnt/working/source_code-git/edk2/OvmfPkg/Library/PlatformInitLib/Platform.c(819):
((BOOLEAN)(0==1))

Adding more log to UpdateVariable() and PlatformValidateNvVarStore(), we
saw some variables which have 0x3C or 0x3D state in store.
e.g.

UpdateVariable(), VariableName=BootOrder
L1871, State=0000003F        <-- VAR_ADDED
State &= VAR_DELETED=0000003D
FlushHobVariableToFlash(), VariableName=BootOrder
...
UpdateVariable(), VariableName=InitialAttemptOrder
L1977, State=0000003F
State &= VAR_IN_DELETED_TRANSITION=0000003E
L2376, State=0000003E
State &= VAR_DELETED=0000003C
FlushHobVariableToFlash(), VariableName=InitialAttemptOrder
...
UpdateVariable(), VariableName=ConIn
L1977, State=0000003F
State &= VAR_IN_DELETED_TRANSITION=0000003E
L2376, State=0000003E
State &= VAR_DELETED=0000003C
FlushHobVariableToFlash(), VariableName=ConIn
...

So, only allowing the four primary states is not enough. This patch changes
the falid states list (Follow Jiewen Yao's suggestion):

1. VAR_HEADER_VALID_ONLY (0x7F)
    - Header added (*)
2. VAR_ADDED (0x3F)
    - Header + data added
3. VAR_ADDED & VAR_IN_DELETED_TRANSITION (0x3E)
    - marked as deleted, but still valid, before new data is added. (*)
4. VAR_ADDED & VAR_IN_DELETED_TRANSITION & VAR_DELETED (0x3C)
    - deleted, after new data is added.
5. VAR_ADDED & VAR_DELETED (0x3D)
    - deleted directly, without new data.
(*) means to support surprise shutdown.

And removed (VAR_IN_DELETED_TRANSITION) and (VAR_DELETED) because they are
invalid states.

v2:
Follow Jiewen Yao's suggestion to add the following valid states:
    VAR_ADDED & VAR_DELETED (0x3D)
    VAR_ADDED & VAR_IN_DELETED_TRANSITION (0x3E)
    VAR_ADDED & VAR_IN_DELETED_TRANSITION & VAR_DELETED (0x3C)
and removed the following invalid states:
    VAR_IN_DELETED_TRANSITION
    VAR_DELETED

Signed-off-by: Chun-Yi Lee <jlee@suse.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoUefiPayloadPkg: Define default values for the DynamicEX PCDs
jdzhang [Mon, 19 Dec 2022 11:59:42 +0000 (19:59 +0800)]
UefiPayloadPkg: Define default values for the DynamicEX PCDs

The following PCDs have no value in UefiPayloadPkg.dsc
and they can not pass the Ecc tool check, so assign
the default values the same as they are in *.dec file.
1. gEfiMdeModulePkgTokenSpaceGuid.PcdAriSupport
2. gEfiMdeModulePkgTokenSpaceGuid.PcdMrIovSupport
3. gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSuppor
4. gEfiMdeModulePkgTokenSpaceGuid.PcdSrIovSystemPageSize
5. gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds
6. gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode
7. gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress
8. gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize

Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: jdzhang <jdzhang@kunluntech.com.cn>
16 months agoCryptoPkg: Need to enable crypto functions
Judah Vang [Mon, 7 Nov 2022 22:15:53 +0000 (06:15 +0800)]
CryptoPkg: Need to enable crypto functions

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

V1: Enable CryptAes for PEI phase. Enable CryptHkdf for SMM phase.
    Update Readme.md

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Nishant C Mistry <nishant.c.mistry@intel.com>
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
Signed-off-by: Nishant C Mistry <nishant.c.mistry@intel.com>
Signed-off-by: Judah Vang <judah.vang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoDynamicTablesPkg: Allow for specified CPU names
Jeff Brasen [Mon, 7 Nov 2022 15:57:11 +0000 (08:57 -0700)]
DynamicTablesPkg: Allow for specified CPU names

Allow object to specify the name of processor and processor container
nodes and the UID of processor containers.

This allows these to be more accurately referenced from other tables.
For example for the _PSL method or the UID in the APMT table.

The UID and Name for processor container may be different as if the
intention is to set names as the corresponding affinity level the UID
may need to be different if there are multiple levels of containers.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
16 months agoUefiPayloadPkg: Move bdsdxe.inf from DXEFV to BDSFV
MarsX Lin [Mon, 19 Dec 2022 02:50:05 +0000 (10:50 +0800)]
UefiPayloadPkg: Move bdsdxe.inf from DXEFV to BDSFV

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

Since UefiPayload had supported multiple fv,
move bdsdxe.inf to new firmware volume and
modify the script of UniversalPayloadPkgBuild.py to
support bdsdxe fv in elf file

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Reviewed-by: James Lu <james.lu@intel.com>
Reviewed-by: Gua Guo <gua.guo@intel.com>
Signed-off-by: MarsX Lin <marsx.lin@intel.com>
16 months agoMdeModulePkg: Supporting S3 in 64bit PEI
Kuo, Ted [Fri, 16 Dec 2022 12:46:27 +0000 (20:46 +0800)]
MdeModulePkg: Supporting S3 in 64bit PEI

https://bugzilla.tianocore.org/show_bug.cgi?id=4195
Transfer from DXE to OS waking vector by calling SwitchStack() when
both are in the same execution mode.

Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Cc: Chinni B Duggapu <chinni.b.duggapu@intel.com>
Signed-off-by: Ted Kuo <ted.kuo@intel.com>
16 months agoUefiCpuPkg: Supporting S3 in 64bit PEI
Kuo, Ted [Fri, 16 Dec 2022 12:46:26 +0000 (20:46 +0800)]
UefiCpuPkg: Supporting S3 in 64bit PEI

https://bugzilla.tianocore.org/show_bug.cgi?id=4195
1.Updated the GDT table in VTF0 to align with the one in S3Resume2Pei.
  By doing so can simplify the changes to enable S3 in 64bit PEI.
2.Use SwitchStack() between PEI and SMM in S3 resume path when both
  are in the same execution mode.
3.Transfer from PEI to OS waking vector by calling SwitchStack() when
  both are in the same execution mode.
4.Removed the debug assertion in S3Resume.c to support 64bit PEI.

Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Ashraf Ali S <ashraf.ali.s@intel.com>
Cc: Chinni B Duggapu <chinni.b.duggapu@intel.com>
Signed-off-by: Ted Kuo <ted.kuo@intel.com>
16 months agoMaintainers: Update OvmfPkg/IoMmuDxe
Min M Xu [Thu, 15 Dec 2022 05:18:10 +0000 (13:18 +0800)]
Maintainers: Update OvmfPkg/IoMmuDxe

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

AmdSevIoMmu.* is renamed as CcIoMmu*. The related section in
Maintainers.txt should be updated as well.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
16 months agoOvmfPkg/IoMmuDxe: Add SEV support for reserved shared memory
Tom Lendacky [Thu, 15 Dec 2022 05:18:09 +0000 (13:18 +0800)]
OvmfPkg/IoMmuDxe: Add SEV support for reserved shared memory

Add support to use the reserved shared memory within the IoMmu library.
This improves boot times for all SEV guests, with SEV-SNP benefiting the
most as it avoids the page state change call to the hypervisor.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
16 months agoOvmfPkg/IoMmuDxe: Rename AmdSevIoMmu to CcIoMmu
Min M Xu [Thu, 15 Dec 2022 05:18:08 +0000 (13:18 +0800)]
OvmfPkg/IoMmuDxe: Rename AmdSevIoMmu to CcIoMmu

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

IoMmuDxe once was designed to support DMA operation when SEV is enabled.
After TDX is enabled in IoMmuDxe, some files' name in IoMmuDxe need to
be more general. So this patch rename:
  AmdSevIoMmu.h -> CcIoMmu.h
  AmdSevIoMmu.c -> CcIoMmu.c

Accordingly there are some udates in IoMmuDxe.c and IoMmuDxe.inf.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
16 months agoOvmfPkg/IoMmuDxe: Reserve shared memory region for DMA operation
Min M Xu [Thu, 15 Dec 2022 05:18:07 +0000 (13:18 +0800)]
OvmfPkg/IoMmuDxe: Reserve shared memory region for DMA operation

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

A typical QEMU fw_cfg read bytes with IOMMU for td guest is that:
(QemuFwCfgReadBytes@QemuFwCfgLib.c is the example)
1) Allocate DMA Access buffer
2) Map actual data buffer
3) start the transfer and wait for the transfer to complete
4) Free DMA Access buffer
5) Un-map actual data buffer

In step 1/2, Private memories are allocated, converted to shared memories.
In Step 4/5 the shared memories are converted to private memories and
accepted again. The final step is to free the pages.

This is time-consuming and impacts td guest's boot perf (both direct boot
and grub boot) badly.

In a typical grub boot, there are about 5000 calls of page allocation and
private/share conversion. Most of page size is less than 32KB.

This patch allocates a memory region and initializes it into pieces of
memory with different sizes. A piece of such memory consists of 2 parts:
the first page is of private memory, and the other pages are shared
memory. This is to meet the layout of common buffer.

When allocating bounce buffer in IoMmuMap(), IoMmuAllocateBounceBuffer()
is called to allocate the buffer. Accordingly when freeing bounce buffer
in IoMmuUnmapWorker(), IoMmuFreeBounceBuffer() is called to free the
bounce buffer. CommonBuffer is allocated by IoMmuAllocateCommonBuffer
and accordingly freed by IoMmuFreeCommonBuffer.

This feature is tested in Intel TDX pre-production platform. It saves up
to hundreds of ms in a grub boot.

Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
16 months agoOvmfPkg: Add reference to new build instructions
Michael Kubacki [Fri, 2 Dec 2022 16:46:43 +0000 (11:46 -0500)]
OvmfPkg: Add reference to new build instructions

Adds a reference to the new build instructions on the TianoCore wiki
that currently describe building with containers and Stuart.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
16 months agoEmulatorPkg: Add reference to new build instructions
Michael Kubacki [Fri, 2 Dec 2022 16:46:26 +0000 (11:46 -0500)]
EmulatorPkg: Add reference to new build instructions

Adds a reference to the new build instructions on the TianoCore wiki
that currently describe building with containers and Stuart.

Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
16 months agoBaseTools: Add reference to new build instructions
Michael Kubacki [Fri, 2 Dec 2022 16:46:09 +0000 (11:46 -0500)]
BaseTools: Add reference to new build instructions

Adds a reference to the new build instructions on the TianoCore wiki
that currently describe building with containers and Stuart.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
16 months agoArmVirtPkg: Add reference to new build instructions
Michael Kubacki [Fri, 2 Dec 2022 16:45:33 +0000 (11:45 -0500)]
ArmVirtPkg: Add reference to new build instructions

Adds a reference to the new build instructions on the TianoCore wiki
that currently describe building with containers and Stuart.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
16 months ago.pytool/Readme.md: Add reference to new build instructions
Michael Kubacki [Fri, 2 Dec 2022 16:45:13 +0000 (11:45 -0500)]
.pytool/Readme.md: Add reference to new build instructions

Adds a reference to the new build instructions on the TianoCore wiki
that currently describe building with containers and Stuart.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
16 months agoOvmfPkg/AcpiPlatformDxe: Differentiate TDX case for Cloud Hypervisor
Sebastien Boeuf [Thu, 15 Dec 2022 15:10:04 +0000 (23:10 +0800)]
OvmfPkg/AcpiPlatformDxe: Differentiate TDX case for Cloud Hypervisor

Rely on CcProbe() to identify when running on TDX so that ACPI tables
can be retrieved differently for Cloud Hypervisor. Instead of relying on
the PVH structure to find the RSDP pointer, the tables are individually
passed through the HOB.

Signed-off-by: Jiaqi Gao <jiaqi.gao@intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/PlatformInitLib: Transfer GUID Extension HOB
Sebastien Boeuf [Thu, 15 Dec 2022 15:10:03 +0000 (23:10 +0800)]
OvmfPkg/PlatformInitLib: Transfer GUID Extension HOB

This is required for passing the ACPI tables from the VMM up to the
guest OS. They are transferred through this GUID extension.

Signed-off-by: Jiaqi Gao <jiaqi.gao@intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/PlatformInitLib: Differentiate TDX case for Cloud Hypervisor
Sebastien Boeuf [Thu, 15 Dec 2022 15:10:02 +0000 (23:10 +0800)]
OvmfPkg/PlatformInitLib: Differentiate TDX case for Cloud Hypervisor

Rely on the CcProbe() function to identify when running on TDX. This
allows the firmware to follow a different codepath for Cloud Hypervisor,
which means it doesn't rely on PVH to find out about memory below 4GiB.
instead it falls back onto the CMOS to retrieve that information.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/AmdSev/SecretDxe: Allocate secret location as EfiACPIReclaimMemory
Dov Murik [Thu, 15 Dec 2022 13:11:51 +0000 (13:11 +0000)]
OvmfPkg/AmdSev/SecretDxe: Allocate secret location as EfiACPIReclaimMemory

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

Commit 079a58276b98 ("OvmfPkg/AmdSev/SecretPei: Mark SEV launch secret
area as reserved") marked the launch secret area itself (1 page) as
reserved so the guest OS can use it during the lifetime of the OS.
However, the address and size of the secret area held in the
CONFIDENTIAL_COMPUTING_SECRET_LOCATION struct are declared as STATIC in
OVMF (in AmdSev/SecretDxe); therefore there's no guarantee that it will
not be written over by OS data.

Fix this by allocating the memory for the
CONFIDENTIAL_COMPUTING_SECRET_LOCATION struct with the
EfiACPIReclaimMemory memory type to ensure the guest OS will not reuse
this memory.

Fixes: 079a58276b98 ("OvmfPkg/AmdSev/SecretPei: Mark SEV launch secret ...")
Signed-off-by: Dov Murik <dovmurik@linux.ibm.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: Validate SEC's GHCB page
Adam Dunlap [Fri, 9 Dec 2022 21:04:16 +0000 (05:04 +0800)]
OvmfPkg/PlatformPei: Validate SEC's GHCB page

When running under SEV-ES, a page of shared memory is allocated for the
GHCB during the SEC phase at address 0x809000. This page of memory is
eventually passed to the OS as EfiConventionalMemory. When running
SEV-SNP, this page is not PVALIDATE'd in the RMP table, meaning that if
the guest OS tries to access the page, it will think that the host has
voilated the security guarantees and will likely crash.

This patch validates this page immediately after EDK2 switches to using
the GHCB page allocated for the PEI phase.

This was tested by writing a UEFI application that reads to and writes
from one byte of each page of memory and checks to see if a #VC
exception is generated indicating that the page was not validated.

Fixes: 6995a1b79bab ("OvmfPkg: Create a GHCB page for use during Sec phase")
Signed-off-by: Adam Dunlap <acdunlap@google.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
16 months agoOvmfPkg/SecTpmMeasurementLib: Fix the mapping error of PCR and RTMR index
Min M Xu [Wed, 14 Dec 2022 07:14:19 +0000 (15:14 +0800)]
OvmfPkg/SecTpmMeasurementLib: Fix the mapping error of PCR and RTMR index

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

TDVF has the feature to do RTMR measurement in SEC phase. In the same time
it builds a GUID hob which carries the hash value of the measurement so
that in DXE phase a td event can be created based on this GUID Hob. There
is a mapping error between TPM PCR index and RTMR index according to UEFI
2.10. That PCR6 is missing in the mapping. This patch fixes this issue.

Cc: Erdem Aktas <erdemaktas@google.com> [ruleof2]
Cc: James Bottomley <jejb@linux.ibm.com> [jejb]
Cc: Jiewen Yao <jiewen.yao@intel.com> [jyao1]
Cc: Tom Lendacky <thomas.lendacky@amd.com> [tlendacky]
Cc: Arti Gupta <ARGU@microsoft.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/TdTcg2Dxe: Fix the mapping error between PCR index and MR index
Min M Xu [Wed, 14 Dec 2022 07:14:18 +0000 (15:14 +0800)]
OvmfPkg/TdTcg2Dxe: Fix the mapping error between PCR index and MR index

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

According to UEFI Spec 2.10 it is supposed to return the mapping from PCR
index to CC MR index:
//
// In the current version, we use the below mapping for TDX:
//
// TPM PCR Index | CC Measurement Register Index | TDX-measurement register
// -----------------------------------------------------------------------
// 0             |   0                           |   MRTD
// 1, 7          |   1                           |   RTMR[0]
// 2~6           |   2                           |   RTMR[1]
// 8~15          |   3                           |   RTMR[2]

In the current implementation TdMapPcrToMrIndex returns the index of RTMR,
not the MR index.

After fix the spec unconsistent, other related codes are updated
accordingly.
1) The index of event log uses the input MrIndex.
2) MrIndex is decreated by 1 before it is sent for RTMR extending.

Cc: Erdem Aktas <erdemaktas@google.com> [ruleof2]
Cc: James Bottomley <jejb@linux.ibm.com> [jejb]
Cc: Jiewen Yao <jiewen.yao@intel.com> [jyao1]
Cc: Tom Lendacky <thomas.lendacky@amd.com> [tlendacky]
Cc: Arti Gupta <ARGU@microsoft.com>
Reported-by: Arti Gupta <ARGU@microsoft.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg/TdTcg2Dxe: Fix incorrect protocol and structure version
Min M Xu [Wed, 14 Dec 2022 07:14:17 +0000 (15:14 +0800)]
OvmfPkg/TdTcg2Dxe: Fix incorrect protocol and structure version

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

According to the Uefi spec 2.10 Section 38.2.2.
EFI_CC_MEASUREMENT_PROTOCOL.GetCapability, the minor version of
StructureVersion and ProtocolVersion should be 0.

Cc: Erdem Aktas <erdemaktas@google.com> [ruleof2]
Cc: James Bottomley <jejb@linux.ibm.com> [jejb]
Cc: Jiewen Yao <jiewen.yao@intel.com> [jyao1]
Cc: Tom Lendacky <thomas.lendacky@amd.com> [tlendacky]
Cc: Arti Gupta <ARGU@microsoft.com>
Reported-by: Arti Gupta <ARGU@microsoft.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoUnitTestFrameworkPkg/UnitTestLib: Print expected Status on ASSERT fail
devel@edk2.groups.io [Wed, 30 Nov 2022 23:02:15 +0000 (15:02 -0800)]
UnitTestFrameworkPkg/UnitTestLib: Print expected Status on ASSERT fail

Update the UnitTestAssertStatusEqual error message to print out the
expected value in addition to the seen value.

Signed-off-by: Jeshua Smith <jeshuas@nvidia.com>
Reviewed-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
16 months agoOvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + mQemuFwCfgDmaSupported
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:09 +0000 (14:10 +0100)]
OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + mQemuFwCfgDmaSupported

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 <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/QemuFwCfgLib: rewrite fw_cfg probe
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:08 +0000 (14:10 +0100)]
OvmfPkg/QemuFwCfgLib: rewrite fw_cfg probe

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 <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/DebugLibIoPort: use Rom version for PEI
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:07 +0000 (14:10 +0100)]
OvmfPkg/DebugLibIoPort: use Rom version for PEI

This variant does not use global variables.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: remove mFeatureControlValue
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:06 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: remove mFeatureControlValue

Use PlatformInfoHob->FeatureControlValue instead.
OnMpServicesAvailable() will find PlatformInfoHob using
GetFirstGuidHob() and pass a pointer to the WriteFeatureControl
callback.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: remove mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:05 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: remove mPlatformInfoHob

Stop using the mPlatformInfoHob global variable.  Let
BuildPlatformInfoHob() allocate and return PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: Verification: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:04 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: Verification: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in S3Verification() and
Q35BoardVerification() functions.  Pass a pointer to the PlatformInfoHob
instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: NoExec: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:03 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: NoExec: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in NoexecDxeInitialization()
function.  Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: MemTypeInfo: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:02 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: MemTypeInfo: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in MemTypeInfoInitialization()
function.  Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: PeiMemory: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:01 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei: PeiMemory: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in PublishPeiMemory()
and GetPeiMemoryCap() functions.  Pass a pointer to the PlatformInfoHob
instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei Q35 SMM helpers: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:10:00 +0000 (14:10 +0100)]
OvmfPkg/PlatformPei Q35 SMM helpers: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in
Q35TsegMbytesInitialization() and
Q35SmramAtDefaultSmbaseInitialization() ) functions.
Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: PeiFv: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:09:59 +0000 (14:09 +0100)]
OvmfPkg/PlatformPei: PeiFv: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in PeiFvInitialization()
function.  Pass a pointer to the PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoOvmfPkg/PlatformPei: AmdSev: stop using mPlatformInfoHob
Gerd Hoffmann [Fri, 2 Dec 2022 13:09:58 +0000 (14:09 +0100)]
OvmfPkg/PlatformPei: AmdSev: stop using mPlatformInfoHob

Stop using the mPlatformInfoHob global variable in AmdSevInitialize()
and AmdSevEsInitialize() functions.  Pass a pointer to the
PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
16 months agoDynamicTablesPkg: SSDT _LPI revision is incorrect
Jeff Brasen [Tue, 15 Nov 2022 18:01:06 +0000 (11:01 -0700)]
DynamicTablesPkg: SSDT _LPI revision is incorrect

_LPI Revision should be 0 per the ACPI 6.5 specification.
"The revision number of the _LPI object. Current revision is 0."

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
16 months agoMdePkg/UnitTestHostBaseLib: Remove HOST_APPLICATION limitation
Liu, Zhiguang [Wed, 7 Dec 2022 01:36:47 +0000 (09:36 +0800)]
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

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
16 months agoUnitTestFrameworkPkg: Modify APIs in UnitTestPersistenceLib
Liu, Zhiguang [Tue, 6 Dec 2022 05:25:43 +0000 (13:25 +0800)]
UnitTestFrameworkPkg: Modify APIs in UnitTestPersistenceLib

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

UnitTestPersistenceLib now consumes private struct definition.
Modify APIs in UnitTestPersistenceLib to make it easy to become
a public library.

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Michael Kubacki <mikuback@linux.microsoft.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
16 months agoMdePkg/BaseCpuLib: Remove assembly for CpuFlushTlb
Liu, Zhiguang [Mon, 12 Dec 2022 07:30:22 +0000 (15:30 +0800)]
MdePkg/BaseCpuLib: Remove assembly for CpuFlushTlb

For different compilers, both IA32 and X64 can use
Ia32/CpuFlushTlbGcc.c, which is C code (no inline assembly code).
To simplify, remove other assemly file for CpuFlushTlb,
and rename Ia32/CpuFlushTlbGcc.c to X86CpuFlushTlb.c.

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
16 months agoMaintainers.txt: Change Anthony's github id
Anthony PERARD [Fri, 16 Sep 2022 15:30:55 +0000 (08:30 -0700)]
Maintainers.txt: Change Anthony's github id

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
16 months agoShellPkg/Shell: Do not set end device path if already end
Michael D Kinney [Fri, 9 Dec 2022 15:53:21 +0000 (07:53 -0800)]
ShellPkg/Shell: Do not set end device path if already end

Update Shell Protocol EfiShellGetMapFromDevicePath() to not
set the end if the device path if it is already an end of
entire device path.  This removes a write operation that can
cause failures if the Device Path Protocol is mapped to
read-only memory.  In general Device Path Protocols should not
be modified unless the API explicitly states that the device
path is modified.

Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zhichao Gao <zhichao.gao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
16 months agoShellPkg/AcpiView: APMT Parser
Jeff Brasen [Fri, 4 Nov 2022 16:04:48 +0000 (10:04 -0600)]
ShellPkg/AcpiView: APMT Parser

Add a new parser for the Arm Performance Monitoring Unit Table.
The APMT table describes the properties of PMU support
implemented by components in an Arm-based system.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
16 months agoMdePkg/IndustryStandard: add definitions for ACPI APMT
Jeff Brasen [Fri, 4 Nov 2022 16:04:47 +0000 (10:04 -0600)]
MdePkg/IndustryStandard: add definitions for ACPI APMT

This adds #defines and struct typedefs for the various node types in
the  ACPI Arm Performance Monitoring Unit (APMT) table.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
16 months agoDynamicTablesPkg: Remove duplicated words
Pierre Gondois [Tue, 6 Sep 2022 08:28:59 +0000 (10:28 +0200)]
DynamicTablesPkg: Remove duplicated words

In an effort to clean the documentation of the above
package, remove duplicated words.

Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
16 months agoMdeModulePkg: SdMmcPciHcDxe: Fix issue that SD1.0 cards can't be recognized
Chevron Li (WH) [Wed, 7 Dec 2022 11:08:39 +0000 (19:08 +0800)]
MdeModulePkg: SdMmcPciHcDxe: Fix issue that SD1.0 cards can't be recognized

SD1.0 cards don't support CMD8 and CMD6
CMD8 result can be used to distinguish the card is SD1.0 or not.
CMD8 result can be used to decide following CMD6 is sent or skip.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Chevron Li <chevron.li@bayhubtech.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
16 months agoMdeModulePkg/Ata: Fix command status reporting
Albecki, Mateusz [Tue, 18 Oct 2022 15:54:19 +0000 (23:54 +0800)]
MdeModulePkg/Ata: Fix command status reporting

Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=4016

AtaAtapiPassThru driver was reporting recovery status on failed command
packets which led to incorrect flows in upper layers and to SCT tests
fails. This commit will change the logic to report command status.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
16 months agoOvmfPkg/SmbiosPlatformDxe: use PcdFirmware*
Gerd Hoffmann [Mon, 28 Nov 2022 05:40:20 +0000 (13:40 +0800)]
OvmfPkg/SmbiosPlatformDxe: use PcdFirmware*

Instead of using hard-coded strings ("0.0.0" for BiosVersion etc)
which is mostly useless read the PCDs (PcdFirmwareVendor,
PcdFirmwareVersionString and PcdFirmwareReleaseDateString) and
build the string table dynamuically at runtime.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agomv OvmfPkg: move fdf include snippets to Include/Fdf
Gerd Hoffmann [Fri, 9 Dec 2022 13:03:48 +0000 (21:03 +0800)]
mv OvmfPkg: move fdf include snippets to Include/Fdf

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg: move dsc include snippet for Network support to Include/Dsc
Gerd Hoffmann [Fri, 9 Dec 2022 13:03:47 +0000 (21:03 +0800)]
OvmfPkg: move dsc include snippet for Network support to Include/Dsc

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg: move dsc and fdf include snippets for TPM support to subdirs
Gerd Hoffmann [Fri, 9 Dec 2022 13:03:46 +0000 (21:03 +0800)]
OvmfPkg: move dsc and fdf include snippets for TPM support to subdirs

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoOvmfPkg: Add INVD case in #VE handler
Ryan Afranji [Thu, 8 Dec 2022 00:51:15 +0000 (08:51 +0800)]
OvmfPkg: Add INVD case in #VE handler

According to the Intel GHCI specification document section 2.4.1, the
goal for instructions that do not have a corresponding TDCALL is for the
handler to treat the instruction as a NOP.

INVD does not have a corresponding TDCALL. This patch makes the #VE
handler treat INVD as a NOP.

Signed-off-by: Ryan Afranji <afranji@google.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
16 months agoMdeModulePkg/DxeCore: Use correct type for alignment mask
Ard Biesheuvel [Wed, 7 Dec 2022 17:49:45 +0000 (18:49 +0100)]
MdeModulePkg/DxeCore: Use correct type for alignment mask

The page allocator code in CoreFindFreePagesI() uses a mask derived from
its UINTN Alignment argument to align the descriptor end address of a
MEMORY_MAP entry to the requested alignment, in order to check whether
the descriptor covers enough sufficiently aligned area to satisfy the
request.

However, on 32-bit architectures, 'Alignment' is a 32-bit type, whereas
DescEnd is a 64-bit type, and so the resulting operation performed on
the end address comes down to masking with 0xfffff000 instead of the
intended 0xffffffff_fffff000. Given the -1 at the end of the expression,
the resulting address is 0xffffffff_fffffffff for any descriptor that
ends on a 4G aligned boundary, and this is certainly not what was
intended.

So cast Alignment to UINT64 to ensure that the mask has the right size.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
16 months agoEmulatorPkg: Record Argc, Argv and Envp in EmuThunk Ppi
Liu, Zhiguang [Tue, 6 Dec 2022 05:41:36 +0000 (13:41 +0800)]
EmulatorPkg: Record Argc, Argv and Envp in EmuThunk Ppi

Record Argc, Argv and Envp in EmuThunk Ppi so that other modules
can use these fields to change behavior depends on boot parameters
or environment.

Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>